72 #pragma warning( disable: 4786)
98#ifdef USEREFICCMAXNAMESPACE
103#define BRIEF_STRING_SIZE (1024)
168 if (m_nReserved != 0) {
172 sReport +=
" - Reserved Value must be zero.\n";
226 if (&UnknownTag ==
this)
279 if (!pIO->
Read32(&m_nType))
320 if (m_nSize && m_pData) {
343 sDescription =
"Unknown Tag Type of ";
344 sprintf(buf,
"%u Bytes.", m_nSize-4);
347 if (nVerboseness > 50) {
348 sDescription +=
"\n\nData Follows:\n";
350 icMemDump(sDescription, m_pData+4, m_nSize-4);
365 m_szText = (
icChar*)malloc(1);
382 m_szText = (
icChar*)malloc(1);
400 if (&TextTag ==
this)
403 m_szText = (
icChar*)malloc(1);
451 if (!pIO->
Read32(&m_nReserved))
456 icChar *pBuf = GetBuffer(nSize);
492 if (!pIO->
Write32(&m_nReserved))
518 sDescription +=
"Text Length = ";
519 if (m_szText && *m_szText) {
521 sprintf(buf,
"%zu bytes\n", strlen(m_szText));
524 sDescription +=
"0 (NULL)";
526 if (nVerboseness > 25) {
527 sDescription +=
"\"";
528 if (m_szText && *m_szText) {
531 sDescription += m_szText;
539 sDescription +=
"\n... <!truncated!>";
542 sDescription +=
"\"\n";
563 icChar *szBuf = GetBuffer(len);
565 strcpy(szBuf, szText);
602 if (m_nBufSize < nSize) {
606 m_szText[nSize] =
'\0';
628 if (nSize < m_nBufSize-1) {
630 m_nBufSize = nSize+1;
664 sReport += sSigPathName;
665 sReport +=
" - Tag must have at least seven text characters.\n";
671 sReport += sSigPathName;
672 sReport +=
" - Unknown Tag.\n";
676 for (i=0; m_szText[i] && i<(int)m_nBufSize; i++) {
677 if (m_szText[i]&0x80) {
679 sReport += sSigPathName;
680 sReport +=
" - Text does not contain just 7-bit data.\n";
687 sReport += sSigPathName;
688 sReport +=
" - Empty Tag.\n";
708 m_szText = (
icUChar*)malloc(1);
725 m_szText = (
icUChar*)malloc(1);
743 if (&TextTag ==
this)
746 m_szText = (
icUChar*)malloc(1);
793 if (!pIO->
Read32(&m_nReserved))
801 icUChar *pBuf = GetBuffer(nSize);
837 if (!pIO->
Write32(&m_nReserved))
863 sDescription +=
"UTF8 Length = ";
864 if (m_szText && *m_szText) {
866 sprintf(buf,
"%d bytes\n", m_nBufSize);
870 sDescription +=
"0 (NULL)";
872 if (nVerboseness > 25) {
873 sDescription +=
"\"";
874 if (m_szText && *m_szText) {
877 sDescription += (
icChar*)m_szText;
885 sDescription +=
"\n... <!truncated!>";
888 sDescription +=
"\"\n";
909 icUChar *szBuf = GetBuffer(len);
933 for (len=0; szText[len]; len++);
937 SetText((
const icUChar*)&text[0]);
973 if (m_nBufSize < nSize) {
977 m_szText[nSize] =
'\0';
1000 if (nSize < m_nBufSize-1) {
1002 m_nBufSize = nSize+1;
1030 sReport += sSigPathName;
1031 sReport +=
" - Empty Tag.\n";
1072 memcpy(m_pZipBuf, ITT.
GetBuffer(), m_nBufSize);
1093 memcpy(m_pZipBuf, ITT.
GetBuffer(), m_nBufSize);
1139 if (!pIO->
Read32(&m_nReserved))
1144 icUChar *pBuf = AllocBuffer(nSize);
1146 if (m_nBufSize && pBuf) {
1178 if (!pIO->
Write32(&m_nReserved))
1202 if (!GetText(str)) {
1203 sDescription +=
"Error! - Unable to decompress text data.\n";
1206 sDescription +=
"Warning! - Correcting for improperly encoded ";
1208 sDescription +=
" tag.\n\n";
1211 sDescription +=
"ZLib Compressed String=\"";
1212 sDescription += str;
1213 sDescription +=
"\"\n";
1216 sprintf(size,
"%d", m_nBufSize);
1217 sDescription +=
"BEGIN_COMPESSED_DATA[\"";
1218 sDescription += size;
1219 sDescription +=
"]\n";
1222 sDescription += str;
1223 sDescription +=
"\n";
1225 sDescription +=
"END_COMPRESSED_DATA\n";
1247 memset(&zstr, 0,
sizeof(zstr));
1248 unsigned char buf[32767] = { 0 };
1250 zstat = inflateInit(&zstr);
1252 if (zstat != Z_OK) {
1256 zstat = inflateReset(&zstr);
1258 if (zstat != Z_OK) {
1264 zstr.next_in = m_pZipBuf+4;
1265 zstr.avail_in = m_nBufSize-4;
1268 zstr.next_in = m_pZipBuf;
1269 zstr.avail_in = m_nBufSize;
1275 zstr.next_out = buf;
1276 zstr.avail_out =
sizeof(buf);
1278 zstat = inflate(&zstr, Z_SYNC_FLUSH);
1280 if (zstat != Z_OK && zstat != Z_STREAM_END) {
1285 n =
sizeof(buf) - zstr.avail_out;
1287 for (i = 0; i < n; i++) {
1290 }
while (zstat != Z_STREAM_END);
1315 icUtf8Vector compress;
1320 unsigned char buf[32767];
1321 memset(&zstr, 0,
sizeof(zstr));
1323 zstat = deflateInit(&zstr, Z_DEFAULT_COMPRESSION);
1325 if (zstat != Z_OK) {
1329 zstat = deflateReset(&zstr);
1330 zstr.next_in = (Bytef*)szText;
1331 zstr.avail_in = nSize;
1333 if (zstat != Z_OK) {
1340 zstr.next_out = buf;
1341 zstr.avail_out =
sizeof(buf);
1343 zstat = deflate(&zstr, Z_FINISH);
1345 if (zstat != Z_OK && zstat != Z_STREAM_END) {
1350 n =
sizeof(buf) - zstr.avail_out;
1352 for (i = 0; i < n; i++) {
1353 compress.push_back(buf[i]);
1355 }
while (zstat != Z_STREAM_END);
1362 for (i = 0; i < (int)m_nBufSize; i++) {
1363 pBuf[i] = compress[i];
1388 for (len=0; szText[len]; len++);
1392 return SetText((
const icUChar*)&text[0]);
1412 if (m_nBufSize != nSize) {
1422 m_pZipBuf = (
icUChar*)malloc(nSize);
1457 sReport += sSigPathName;
1458 sReport +=
" - Empty Tag.\n";
1464 if (!GetText(sText)) {
1466 sReport += sSigPathName;
1467 sReport +=
" - Unable to get text for tag (possibly corrupt compressed data).\n";
1472 sReport += sSigPathName;
1473 sReport +=
" - Improperly encoded ";
1475 sReport +=
" tag.\n";
1480 sReport += sSigPathName;
1481 sReport +=
" - Zip compression not supported by CMM - unable to validate text compression.\n";
1536 if (&TextTag ==
this)
1571 if (!m_szText || !m_nBufSize)
1574 for (n=0; n<m_nBufSize && m_szText[n]; n++);
1605 if (!pIO->
Read32(&m_nReserved))
1646 if (!pIO->
Write32(&m_nReserved))
1674 sDescription +=
"UTF16 Length = ";
1675 if (m_szText && *m_szText) {
1677 sprintf(buf,
"%d bytes\n", m_nBufSize);
1678 sDescription += buf;
1681 sDescription +=
"0 (NULL)";
1683 if (nVerboseness > 25) {
1684 sDescription +=
"\"";
1685 if (m_szText && *m_szText) {
1689 sDescription += GetText(s);
1696 sDescription += buf;
1697 sDescription +=
"\n... <!truncated!>";
1700 sDescription +=
"\"\n";
1723 icUtf8Vector::iterator c;
1725 if (str.size()>2 && (str[0]==0xff && str[1]==0xfe)) {
1728 for (; c!=str.end(); c++)
1753 for (n=0; szText[n]; n++);
1758 memcpy(szBuf, szText, len*
sizeof(
icUChar16));
1783 if (str[0]==0xfeff) {
1791 memcpy(m_szText, &str[pos], nSize*
sizeof(
icUChar));
1828 if (m_nBufSize < nSize) {
1831 m_szText[nSize] = 0;
1851 if (nSize < m_nBufSize-1) {
1853 m_nBufSize = nSize+1;
1881 sReport += sSigPathName;
1882 sReport +=
" - Empty Tag.\n";
1901 m_szText = (
icChar*)malloc(1);
1906 m_uzUnicodeText[0] = 0;
1908 m_nUnicodeLanguageCode = 0;
1912 memset(m_szScriptText, 0,
sizeof(m_szScriptText));
1914 m_bInvalidScript =
false;
1936 m_szText = (
icChar*)malloc(m_nASCIISize *
sizeof(
icChar));
1941 m_szText = (
icChar*)calloc(m_nASCIISize,
sizeof(
icChar));
1945 if (m_nUnicodeSize) {
1952 m_uzUnicodeText[0] = 0;
1955 memcpy(m_szScriptText, ITTD.
m_szScriptText,
sizeof(m_szScriptText));
1973 if (&TextDescTag ==
this)
1985 m_szText = (
icChar*)calloc(m_nASCIISize,
sizeof(
icChar));
1986 memcpy(m_szText, TextDescTag.
m_szText, m_nASCIISize*
sizeof(
icChar));
1990 m_szText = (
icChar*)calloc(m_nASCIISize,
sizeof(
icChar));
1994 if (m_uzUnicodeText)
1995 free(m_uzUnicodeText);
1996 if (m_nUnicodeSize) {
2003 m_uzUnicodeText[0] = 0;
2006 memcpy(m_szScriptText, TextDescTag.
m_szScriptText,
sizeof(m_szScriptText));
2024 free(m_uzUnicodeText);
2047 nEnd = pIO->
Tell() + size;
2055 !pIO->
Read32(&m_nReserved) ||
2062 icChar *pBuf = GetBuffer(nSize);
2077 if (!pIO->
Read32(&m_nUnicodeLanguageCode) ||
2082 if (nSize == 0xFFFFFFFF)
2100 if (!pIO->
Read16(&m_nScriptCode) ||
2101 !pIO->
Read8(&m_nScriptSize))
2105 m_nScriptSize >
sizeof(m_szScriptText))
2108 int nScriptLen = pIO->
Read8(m_szScriptText, 67);
2113 if (nScriptLen<67) {
2114 memset(&m_szScriptText[0], 0, 67-nScriptLen);
2115 m_bInvalidScript =
true;
2143 !pIO->
Write32(&m_nReserved) ||
2152 if (!pIO->
Write32(&m_nUnicodeLanguageCode))
2155 if (m_nUnicodeSize > 1) {
2156 if (!pIO->
Write32(&m_nUnicodeSize) ||
2165 if (!pIO->
Write16(&m_nScriptCode) ||
2166 !pIO->
Write8(&m_nScriptSize) ||
2167 pIO->
Write8(m_szScriptText, 67)!= 67)
2170 m_bInvalidScript =
false;
2187 sDescription +=
"TextDescription Length = ";
2188 if (m_szText && *m_szText) {
2190 sprintf(buf,
"%zu bytes\n", strlen(m_szText));
2191 sDescription += buf;
2194 sDescription +=
"0 (NULL)";
2196 if (nVerboseness > 25) {
2197 sDescription +=
"\"";
2198 if (m_szText && *m_szText) {
2201 sDescription += m_szText;
2208 sDescription += buf;
2209 sDescription +=
"\n... <!truncated!>";
2212 sDescription +=
"\"\n";
2229 m_bInvalidScript =
false;
2235 icChar *szBuf = GetBuffer(len);
2237 strcpy(szBuf, szText);
2274 if (m_nASCIISize < nSize) {
2277 m_szText[nSize] =
'\0';
2279 m_nASCIISize = nSize;
2297 if (nSize < m_nASCIISize-1) {
2299 m_nASCIISize = nSize+1;
2318 if (m_nUnicodeSize < nSize) {
2321 m_uzUnicodeText[nSize] = 0;
2323 m_nUnicodeSize = nSize;
2326 return m_uzUnicodeText;
2340 for (i=0; m_uzUnicodeText[i]; i++);
2344 if (nSize < m_nUnicodeSize-1) {
2346 m_nUnicodeSize = nSize+1;
2372 if (m_nScriptSize>67) {
2374 sReport += sSigPathName;
2375 sReport +=
" - ScriptCode count must not be greater than 67.\n";
2380 if (m_bInvalidScript) {
2382 sReport += sSigPathName;
2383 sReport +=
" - ScriptCode must contain 67 bytes.\n";
2401 m_nSig = 0x3f3f3f3f;
2435 if (&SignatureTag ==
this)
2438 m_nSig = SignatureTag.
m_nSig;
2478 m_nSig = 0x3f3f3f3f;
2485 if (!pIO->
Read32(&m_nReserved))
2488 if (!pIO->
Read32(&m_nSig))
2517 if (!pIO->
Write32(&m_nReserved))
2542 sDescription +=
"\n";
2602 sReport += sSigPathName;
2603 sprintf(buf,
" - %s: Unknown Technology.\n", Info.
GetSigName(m_nSig));
2618 sReport += sSigPathName;
2619 sprintf(buf,
" - %s: Unknown Reference Medium Gamut.\n", Info.
GetSigName(m_nSig));
2637 sReport += sSigPathName;
2638 sprintf(buf,
" - %s: Unknown Colorimetric Intent Image State.\n", Info.
GetSigName(m_nSig));
2662 m_nSize = nSize <1 ? 1 : nSize;
2664 m_nDeviceCoords = nDeviceCoords;
2665 if (nDeviceCoords<0)
2666 m_nDeviceCoords = nDeviceCoords = 0;
2668 if (nDeviceCoords>0)
2671 m_szPrefix[0] =
'\0';
2672 m_szSufix[0] =
'\0';
2676 m_nColorEntrySize = 32 + (3 + 1 + nDeviceCoords)*
sizeof(
icFloatNumber);
2704 memcpy(m_szPrefix, ITNC.
m_szPrefix,
sizeof(m_szPrefix));
2705 memcpy(m_szSufix, ITNC.
m_szSufix,
sizeof(m_szSufix));
2708 memcpy(m_NamedColor, ITNC.
m_NamedColor, m_nColorEntrySize*m_nSize);
2726 if (&NamedColor2Tag ==
this)
2732 m_nSize = NamedColor2Tag.
m_nSize;
2734 m_csPCS = NamedColor2Tag.
m_csPCS;
2737 memcpy(m_szPrefix, NamedColor2Tag.
m_szPrefix,
sizeof(m_szPrefix));
2738 memcpy(m_szSufix, NamedColor2Tag.
m_szSufix,
sizeof(m_szSufix));
2743 memcpy(m_NamedColor, NamedColor2Tag.
m_NamedColor, m_nColorEntrySize*m_nSize);
2765 delete [] m_NamedLab;
2783 if (nDeviceCoords<0)
2784 nDeviceCoords = m_nDeviceCoords;
2788 if (nDeviceCoords>0)
2801 for (i=0; i<nCopy; i++) {
2809 for (j=0; j<nCoords; j++) {
2815 m_nColorEntrySize = nColorEntrySize;
2817 m_NamedColor = pNamedColor;
2819 m_nDeviceCoords = nNewCoords;
2839 strncpy(m_szPrefix, szPrefix,
sizeof(m_szPrefix));
2840 m_szPrefix[
sizeof(m_szPrefix)-1]=
'\0';
2856 strncpy(m_szSufix, szSufix,
sizeof(m_szSufix));
2857 m_szSufix[
sizeof(m_szSufix)-1]=
'\0';
2885 sizeof(m_szPrefix) +
2887 if (nTagHdrSize > size)
2895 !pIO->
Read32(&m_nReserved) ||
2896 !pIO->
Read32(&m_nVendorFlags) ||
2898 !pIO->
Read32(&nCoords) ||
2899 pIO->
Read8(m_szPrefix,
sizeof(m_szPrefix))!=
sizeof(m_szPrefix) ||
2900 pIO->
Read8(m_szSufix,
sizeof(m_szSufix))!=
sizeof(m_szSufix)) {
2904 size -= nTagHdrSize;
2911 if (!SetSize(nNum, nCoords))
2917 for (i=0; i<nNum; i++) {
2955 if (!pIO->
Write32(&m_nReserved))
2958 if (!pIO->
Write32(&m_nVendorFlags))
2964 if (!pIO->
Write32(&m_nDeviceCoords))
2967 if (!pIO->
Write8(m_szPrefix,
sizeof(m_szPrefix)))
2970 if (!pIO->
Write8(m_szSufix,
sizeof(m_szSufix)))
2976 for (i=0; i<m_nSize; i++) {
2980 if (m_nDeviceCoords) {
3003 icChar buf[128], szColorVal[40], szColor[40];
3008 sDescription.reserve(sDescription.size() + m_nSize*79);
3010 sprintf(buf,
"BEGIN_NAMED_COLORS flags=%08x %u %u\n", m_nVendorFlags, m_nSize, m_nDeviceCoords);
3011 sDescription += buf;
3013 sprintf(buf,
"Prefix=\"%s\"\n", m_szPrefix);
3014 sDescription += buf;
3016 sprintf(buf,
"Sufix= \"%s\"\n", m_szSufix);
3017 sDescription += buf;
3019 for (i=0; i<m_nSize; i++) {
3020 sprintf(buf,
"Color[%u]: %s :", i, pNamedColor->
rootName);
3021 sDescription += buf;
3025 pcsCoord[j] = pNamedColor->
pcsCoords[j];
3029 pcsCoord[j] = (
icFloatNumber)(pcsCoord[j] * 65535.0 / 65280.0);
3032 for (j=0; j<3; j++) {
3035 sprintf(buf,
" %s=%s", szColor, szColorVal);
3036 sDescription += buf;
3038 if (m_nDeviceCoords) {
3039 sDescription +=
" :";
3040 for (j=0; j<m_nDeviceCoords; j++) {
3043 sprintf(buf,
" %s=%s", szColor, szColorVal);
3044 sDescription += buf;
3047 sDescription +=
"\n";
3068 m_csDevice = csDevice;
3087 if (
stricmp(m_NamedColor[i].rootName,szRootColor) == 0)
3106 delete [] m_NamedLab;
3132 pLab = m_NamedLab[i].
lab;
3133 pXYZ = m_NamedColor[i].pcsCoords;
3140 pLab = m_NamedLab[i].lab;
3141 Lab2ToLab4(pLab, m_NamedColor[i].pcsCoords);
3176 Lab2ToLab4(pLabIn, pPCS);
3184 pLab = m_NamedLab[i].lab;
3193 if (dCalcDE<dMinDE) {
3194 if (dCalcDE<dLeastDE) {
3201 return leastDEindex;
3221 InitFindCachedPCSColor();
3223 return FindCachedPCSColor(pPCS, dMinDE);
3241 std::string sColorName;
3246 if (strncmp(szColor, m_szPrefix, j))
3253 if (strncmp(szColor+(i-j), m_szSufix, j))
3259 sColorName = m_szPrefix;
3260 sColorName += m_NamedColor[i].rootName;
3261 sColorName += m_szSufix;
3263 if (strcmp(sColorName.c_str(),szColor) == 0)
3285 if (!m_nDeviceCoords)
3294 pDevOut = m_NamedColor[i].deviceCoords;
3297 dCalcDiff += (pDevColor[j]-pDevOut[j])*(pDevColor[j]-pDevOut[j]);
3302 dLeastDiff = dCalcDiff;
3306 if (dCalcDiff<dLeastDiff) {
3307 dLeastDiff = dCalcDiff;
3314 return leastDiffindex;
3337 sColorName += m_szPrefix;
3339 sColorName += pNamedColor->
rootName;
3340 sColorName += m_szSufix;
3452 sReport += sSigPathName;
3453 sReport +=
" - Empty tag!\n";
3457 if (m_nDeviceCoords) {
3460 if (m_nDeviceCoords != nCoords) {
3462 sReport += sSigPathName;
3463 sReport +=
" - Incorrect number of device co-ordinates.\n";
3469 sReport += sSigPathName;
3470 sReport +=
" - Tag validation incomplete: Pointer to profile unavailable.\n";
3532 if (&XYZTag ==
this)
3591 if (!pIO->
Read32(&m_nReserved))
3630 if (!pIO->
Write32(&m_nReserved))
3657 if (m_nSize == 1 ) {
3658 sprintf(buf,
"X=%.4lf, Y=%.4lf, Z=%.4lf\n",
icFtoD(m_XYZ[0].X),
icFtoD(m_XYZ[0].Y),
icFtoD(m_XYZ[0].Z));
3659 sDescription += buf;
3663 sDescription.reserve(sDescription.size() + m_nSize*79);
3665 for (i=0; i<m_nSize; i++) {
3666 sprintf(buf,
"value[%u]: X=%.4lf, Y=%.4lf, Z=%.4lf\n", i,
icFtoD(m_XYZ[i].X),
icFtoD(m_XYZ[i].Y),
icFtoD(m_XYZ[i].Z));
3667 sDescription += buf;
3695 if (bZeroNew && m_nSize < nSize) {
3696 memset(&m_XYZ[m_nSize], 0, (nSize-m_nSize)*
sizeof(
icXYZNumber));
3727 sReport += sSigPathName;
3728 sReport +=
" - Empty tag.\n";
3734 for (
int i=0; i<(int)m_nSize; i++) {
3755 m_nChannels = nSize;
3793 if (&ChromTag ==
this)
3854 if (!pIO->
Read32(&m_nReserved))
3857 if (!pIO->
Read16(&nChannels) ||
3858 !pIO->
Read16(&m_nColorantType))
3864 if (nNum < nChannels)
3904 if (!pIO->
Write32(&m_nReserved))
3907 if (!pIO->
Write16(&m_nChannels))
3910 if (!pIO->
Write16(&m_nColorantType))
3939 sprintf(buf,
"Number of Channels : %u\n", m_nChannels);
3940 sDescription += buf;
3943 sDescription += buf;
3945 for (i=0; i<m_nChannels; i++) {
3946 sprintf(buf,
"value[%u]: x=%.3lf, y=%.3lf\n", i,
icUFtoD(m_xy[i].x),
icUFtoD(m_xy[i].y));
3947 sDescription += buf;
3965 if (m_nChannels == nSize)
3975 if (bZeroNew && nSize > m_nChannels) {
3979 m_nChannels = nSize;
4005 if (m_nColorantType) {
4007 if (m_nChannels!=3) {
4009 sReport += sSigPathName;
4010 sReport +=
" - Number of device channels must be three.\n";
4014 switch(m_nColorantType) {
4021 sReport += sSigPathName;
4022 sReport +=
" - Chromaticity data does not match specification.\n";
4034 sReport += sSigPathName;
4035 sReport +=
" - Chromaticity data does not match specification.\n";
4047 sReport += sSigPathName;
4048 sReport +=
" - Chromaticity data does not match specification.\n";
4060 sReport += sSigPathName;
4061 sReport +=
" - Chromaticity data does not match specification.\n";
4070 sReport += sSigPathName;
4071 sReport +=
" - Invalid colorant type encoding.\n";
4094 m_nColorPrimaries = 0;
4095 m_nTransferCharacteristics = 0;
4096 m_nMatrixCoefficients = 0;
4097 m_nVideoFullRangeFlag = 0;
4129 if (&cicpTag ==
this)
4184 if (!pIO->
Read32(&m_nReserved))
4187 if (!pIO->
Read8(&m_nColorPrimaries) ||
4188 !pIO->
Read8(&m_nTransferCharacteristics) ||
4189 !pIO->
Read8(&m_nMatrixCoefficients) ||
4190 !pIO->
Read8(&m_nVideoFullRangeFlag))
4220 if (!pIO->
Write32(&m_nReserved))
4223 if (!pIO->
Write8(&m_nColorPrimaries) ||
4224 !pIO->
Write8(&m_nTransferCharacteristics) ||
4225 !pIO->
Write8(&m_nMatrixCoefficients) ||
4226 !pIO->
Write8(&m_nVideoFullRangeFlag))
4237 {
"1-1-0-0",
"RGB narrow range representation specified in Recommendation ITU-R BT.709-6, Item 3.4"},
4238 {
"1-13-0-1",
"RGB full range representation specified in IEC 61966-2-1 sRGB"},
4239 {
"9-14-0-0",
"R’G’B’ narrow range representation specified in Recommendation ITU-R BT.2020-2, Table 5"},
4240 {
"9-16-0-0",
"PQ R’G’B’ narrow range representation specified in Recommendation ITU-R BT.2100-2, Table 9"},
4241 {
"9-16-0-1",
"PQ R’G’B’ full range representation specified in Recommendation ITU-R BT.2100-2, Table 9"},
4242 {
"9-18-0-0 ",
"HLG R’G’B’ narrow range representation specified in Recommendation ITU-R BT.2100-2 "},
4243 {
"9-18-0-1",
"HLG R’G’B’ full range representation specified in Recommendation ITU-R BT.2100-2"},
4244 {
"1-1-1-0 ",
"YCbCr representation specified in Recommendation ITU-R BT.709-6, Item 3.4"},
4245 {
"9-14-9-0",
"Y’Cb’Cr’ narrow range representation specified in Recommendation ITU-R BT.2020-2, Table 5"},
4246 {
"9-16-9-0",
"PQ Y’Cb’Cr’ narrow range representation specified in Recommendation ITU-R BT.2100-2, Table 9"},
4247 {
"9-16-14-0",
"PQ ICtCp narrow range representation specified in Recommendation ITU-R BT.2100-2, Table 9"},
4248 {
"9-18-9-0",
"HLG Y’Cb’Cr’ narrow range representation specified in Recommendation ITU-R BT.2100-2"},
4249 {
"9-18-14-0 ",
"HLG ICtCp narrow range representation specified in Recommendation ITU-R BT.2100-2"},
4266 sprintf(
code,
"%u-%u-%u-%u", m_nColorPrimaries, m_nTransferCharacteristics, m_nMatrixCoefficients, m_nVideoFullRangeFlag);
4268 sprintf(buf,
"ColorPrimaries=%u\r\n", m_nColorPrimaries);
4269 sDescription += buf;
4271 sprintf(buf,
"TransferCharacteristics=%u\r\n", m_nTransferCharacteristics);
4272 sDescription += buf;
4274 sprintf(buf,
"MatrixCoefficients=%u\r\n", m_nMatrixCoefficients);
4275 sDescription += buf;
4277 sprintf(buf,
"VideoFullRangeFlag=%u\r\n\r\n", m_nVideoFullRangeFlag);
4278 sDescription += buf;
4280 sprintf(buf,
"Combined Code: %s\r\n",
code);
4281 sDescription += buf;
4288 sDescription +=
"Interpretation: ";
4293 sDescription +=
"unknown";
4295 sDescription +=
"\r\n";
4314 colorPrimaries = m_nColorPrimaries;
4315 transferCharacteristics = m_nTransferCharacteristics;
4316 matrixCoefficients = m_nMatrixCoefficients;
4317 videoFullRangeFlag = m_nVideoFullRangeFlag;
4336 m_nColorPrimaries = colorPrimaries;
4337 m_nTransferCharacteristics = transferCharacteristics;
4338 m_nMatrixCoefficients =matrixCoefficients;
4339 m_nVideoFullRangeFlag = videoFullRangeFlag;
4368 if ((pProfile->m_Header.colorSpace ==
icSigRgbData || pProfile->m_Header.colorSpace ==
icSigXYZData) && m_nMatrixCoefficients) {
4370 sReport += sSigPathName;
4371 sReport +=
" - CICP MatrixCoefficients not zero for RGB or XYZ colour space data.\r\n";
4375 if (pProfile->m_Header.colorSpace ==
icSigYCbCrData && !m_nMatrixCoefficients) {
4377 sReport += sSigPathName;
4378 sReport +=
" - CICP MatrixCoefficients zero for YCbCr colour space data.\r\n";
4400 m_nSize = nNumMatrices;
4401 m_nChannelsPerMatrix = nChannelsPerMatrix;
4406 if (nChannelsPerMatrix<4)
4407 m_nChannelsPerMatrix = 4;
4409 m_RawData = (
icUInt8Number*)calloc(m_nSize, GetBytesPerMatrix());
4411 m_bNonZeroPadding =
false;
4431 m_RawData = (
icUInt8Number*)calloc(m_nSize, GetBytesPerMatrix());
4432 memcpy(m_RawData, ITSMA.
m_RawData, m_nSize*GetBytesPerMatrix());
4458 m_RawData = (
icUInt8Number*)calloc(m_nSize, m_nChannelsPerMatrix);
4459 memcpy(m_RawData, ITSMA.
m_RawData, m_nSize*GetBytesPerMatrix());
4518 !pIO->
Read32(&m_nReserved) ||
4519 !pIO->
Read16(&nChannels) ||
4520 !pIO->
Read16(&nMatrixType) ||
4521 !pIO->
Read32(&nNumMatrices))
4528 Reset(nNumMatrices, nChannels);
4529 nBytesPerMatrix = GetBytesPerMatrix();
4539 m_bNonZeroPadding =
false;
4542 for (i=0; i<(int)m_nSize; i++) {
4549 if (pIO->
Read16(pMatrix, 2)!=2) {
4584 nAligned = ((pos+3)/4)*4;
4585 if (nAligned != pos) {
4590 char zbuf[3] = { 0 };
4591 if (pIO->
Read8(&zbuf[0], n)!=n)
4593 for (j=0; j<(int)n; j++) {
4595 m_bNonZeroPadding =
true;
4602 switch(m_nMatrixType) {
4649 nAligned = ((pos+3)/4)*4;
4650 if (nAligned != pos) {
4656 if (pIO->
Read8(&zbuf[0], n)!=n)
4658 for (j=0; j<(int)n; j++) {
4660 m_bNonZeroPadding =
true;
4669 for (i=0; i<(int)nSizeLeft; i++) {
4670 if (!pIO->
Read8(&b))
4673 m_bNonZeroPadding =
true;
4704 !pIO->
Write32(&m_nReserved) ||
4705 !pIO->
Write16(&m_nChannelsPerMatrix) ||
4715 for (i=0; i<(int)m_nSize; i++) {
4722 if (pIO->
Write16(pMatrix, nRows+3)!=nRows+3 ||
4723 pIO->
Write16(mtx.GetColumnsForRow(0), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4730 switch(m_nMatrixType) {
4732 if (pIO->
WriteUInt8Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4737 if (pIO->
WriteUInt16Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4742 if (pIO->
WriteFloat16Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4747 if (pIO->
WriteFloat32Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4777 sDescription +=
"Begin_SparseMatrix_Array\n";
4778 sprintf(buf,
"OutputChannels = %d\n", m_nChannelsPerMatrix);
4779 sDescription += buf;
4780 sprintf(buf,
"MatrixType = %d\n", m_nMatrixType);
4781 sDescription += buf;
4785 for (i=0; i<(int)m_nSize; i++) {
4788 sprintf(buf,
"\nBegin_Matrix_%d\n", i);
4789 sDescription += buf;
4793 for (r=0; r<mtx.
Rows(); r++) {
4796 sprintf(buf,
"Row%d:", r);
4797 sDescription += buf;
4799 for (c=rs; c<re; c++) {
4800 sprintf(buf,
" (%d, %.4lf)", cols[c], mtx.
GetData()->
get(c));
4801 sDescription += buf;
4805 sprintf(buf,
"End_Matrix_%d\n", i);
4806 sDescription += buf;
4808 sDescription +=
"\nEnd_SparseMatrix_Array\n";
4830 switch(m_nMatrixType) {
4838 sReport += sSigPathName;
4839 sReport +=
" - Invalid Sparse Matrix Type.\n";
4844 bool bCheckPCS=
false;
4853 if (bCheckPCS && pProfile) {
4856 sReport += sSigPathName;
4857 sReport +=
" - SparseMatrix data incompatible with spectral PCS.\n";
4862 sReport += sSigPathName;
4863 sReport +=
" - SparseMatrix Output channels doesn't match spectral PCS channels.\n";
4868 if (m_bNonZeroPadding) {
4870 sReport += sSigPathName;
4871 sReport +=
" - Non zero padding in matrices used.\n";
4877 sReport += sSigPathName;
4878 sReport +=
" - No Matrices Defined.\n";
4885 sReport += sSigPathName;
4886 sReport +=
" - Data dont defined for matrices\n";
4904 for (i=0; i<(int)m_nSize; i++) {
4906 if (mtx.
Rows() != nRows || mtx.
Cols() != nCols) {
4908 sReport += sSigPathName;
4909 sprintf(buf,
" - Matrix[%d] doesn't have matching rows and columns.\n", i);
4916 sReport += sSigPathName;
4917 sprintf(buf,
" - Matrix[%d] entries exceeds number supported by Output channels.\n", i);
4924 sReport += sSigPathName;
4925 sprintf(buf,
" - Matrix[%d] has an invalid matrix structure.\n", i);
4930 if (i<(
int)(m_nSize-1)) {
4934 umtx.
Init(nRows, nCols);
4935 if (!umtx.
Union(mtx, mtx2)) {
4937 sReport += sSigPathName;
4938 sprintf(buf,
" - Interpolation from Matrix[%d] exceeds number of supported Output channels.\n", i);
4964 if (nNumMatrices==m_nSize && nChannelsPerMatrix==m_nChannelsPerMatrix)
4967 m_nSize = nNumMatrices;
4968 m_nChannelsPerMatrix = nChannelsPerMatrix;
4979 memset(m_RawData, 0, nSize);
4997 if (nIndex<0 || nIndex>(
int)m_nSize) {
5012 if (nVectorSize!=nBytesPerMatrix)
5014 if (nStart % nBytesPerMatrix != 0)
5017 if (nStart / nBytesPerMatrix > m_nSize)
5020 memcpy(DstVector, m_RawData+nStart, nVectorSize);
5041 if (!nMatrix || nVectorSize != GetBytesPerMatrix())
5046 else if (nMatrix<=1)
5058 if (iPos == nMatrix-1) {
5071 lo = &m_RawData[(iPos-1)*nVectorSize];
5072 hi = &lo[nVectorSize];
5076 lo = &m_RawData[iPos*nVectorSize];
5077 hi = &lo[nVectorSize];
5087 if (!dst.
Interp(1.0f-x, mlo, x, mhi))
5124template <
class T, icTagTypeSignature Tsig>
5130 m_Num = (T*)calloc(nSize,
sizeof(T));
5144template <
class T, icTagTypeSignature Tsig>
5148 m_Num = (T*)calloc(m_nSize,
sizeof(T));
5149 memcpy(m_Num, ITFN.
m_Num, m_nSize*
sizeof(T));
5163template <
class T, icTagTypeSignature Tsig>
5173 m_Num = (T*)calloc(m_nSize,
sizeof(T));
5174 memcpy(m_Num, ITFN.
m_Num, m_nSize*
sizeof(T));
5189template <
class T, icTagTypeSignature Tsig>
5204template <
class T, icTagTypeSignature Tsig>
5208 return "CIccTagS15Fixed16";
5210 return "CIccTagU16Fixed16";
5228template <
class T, icTagTypeSignature Tsig>
5245 if (!pIO->
Read32(&m_nReserved))
5250 if (!SetSize(nSize))
5273template <
class T, icTagTypeSignature Tsig>
5284 if (!pIO->
Write32(&m_nReserved))
5303template <
class T, icTagTypeSignature Tsig>
5308 if (m_nSize == 1 ) {
5310 sprintf(buf,
"Value = %.4lf\n",
icFtoD(m_Num[0]));
5312 sprintf(buf,
"Value = %.4lf\n",
icUFtoD(m_Num[0]));
5313 sDescription += buf;
5319 sDescription +=
"Matrix Form:\n";
5322 sDescription +=
"\nArrayForm:\n";
5324 sDescription.reserve(sDescription.size() + m_nSize*79);
5326 for (i=0; i<m_nSize; i++) {
5328 sprintf(buf,
"Value[%u] = %8.4lf\n", i,
icFtoD(m_Num[i]));
5330 sprintf(buf,
"Value[%u] = %8.4lf\n", i,
icUFtoD(m_Num[i]));
5331 sDescription += buf;
5347template <
class T, icTagTypeSignature Tsig>
5353 m_Num = (T*)
icRealloc(m_Num, nSize*
sizeof(T));
5360 if (bZeroNew && m_nSize < nSize) {
5361 memset(&m_Num[m_nSize], 0, (nSize-m_nSize)*
sizeof(T));
5379template <
class T, icTagTypeSignature Tsig>
5382 if (nVectorSize+nStart >m_nSize)
5389 for (i=0; i<m_nSize; i++) {
5394 for (i=0; i<m_nSize; i++) {
5416template <
class T, icTagTypeSignature Tsig>
5427 else if (nVector<=1)
5439 if (iPos == nVector-1) {
5452 lo = &m_Num[(iPos-1)*nVectorSize];
5453 hi = &lo[nVectorSize];
5457 lo = &m_Num[iPos*nVectorSize];
5458 hi = &lo[nVectorSize];
5466 for (i=0; i<m_nSize; i++) {
5471 for (i=0; i<m_nSize; i++) {
5478 for (i=0; i<m_nSize; i++) {
5483 for (i=0; i<m_nSize; i++) {
5506template <
class T, icTagTypeSignature Tsig>
5524 bNoZero = (lv!=0.0);
5527 DstPos = val/lv - 1.0f;
5532 for (i=1; i<m_nSize; i++, lv=nv) {
5544 DstPos = (val-lv)/(nv-lv) + i - 1.0f;
5568template <
class T, icTagTypeSignature Tsig>
5574 m_Num = (T*)calloc(nSize,
sizeof(T));
5588template <
class T, icTagTypeSignature Tsig>
5593 m_Num = (T*)calloc(m_nSize,
sizeof(T));
5594 memcpy(m_Num, ITNum.
m_Num, m_nSize *
sizeof(T));
5608template <
class T, icTagTypeSignature Tsig>
5616 m_Num = (T*)calloc(m_nSize,
sizeof(T));
5617 memcpy(m_Num, ITNum.
m_Num, m_nSize *
sizeof(T));
5632template <
class T, icTagTypeSignature Tsig>
5647template <
class T, icTagTypeSignature Tsig>
5651 return "CIccTagUInt8";
5653 return "CIccTagUInt16";
5655 return "CIccTagUInt32";
5657 return "CIccTagUInt64";
5659 return "CIccTagNum<>";
5677template <
class T, icTagTypeSignature Tsig>
5694 if (!pIO->
Read32(&m_nReserved))
5699 if (!SetSize(nSize))
5738template <
class T, icTagTypeSignature Tsig>
5749 if (!pIO->
Write32(&m_nReserved))
5785template <
class T, icTagTypeSignature Tsig>
5790 if (m_nSize == 1 ) {
5791 switch (
sizeof(T)) {
5793 sprintf(buf,
"Value = %u (0x02%x)\n", m_Num[0], m_Num[0]);
5796 sprintf(buf,
"Value = %u (0x04%x)\n", m_Num[0], m_Num[0]);
5799 sprintf(buf,
"Value = %u (0x08%x)\n", m_Num[0], m_Num[0]);
5802 sprintf(buf,
"Value = %u (0x016%x)\n", m_Num[0], m_Num[0]);
5805 sprintf(buf,
"Value = %u (0x%x)\n", m_Num[0], m_Num[0]);
5808 sDescription += buf;
5812 sDescription.reserve(sDescription.size() + m_nSize*79);
5814 for (i=0; i<m_nSize; i++) {
5815 switch (
sizeof(T)) {
5817 sprintf(buf,
"Value = %u (0x02%x)\n", m_Num[i], m_Num[i]);
5820 sprintf(buf,
"Value = %u (0x04%x)\n", m_Num[i], m_Num[i]);
5823 sprintf(buf,
"Value = %u (0x08%x)\n", m_Num[i], m_Num[i]);
5826 sprintf(buf,
"Value = %u (0x016%x)\n", m_Num[i], m_Num[i]);
5829 sprintf(buf,
"Value = %u (0x%x)\n", m_Num[i], m_Num[i]);
5832 sDescription += buf;
5837template <
class T, icTagTypeSignature Tsig>
5849 sReport += sSigPathName;
5850 sReport +=
" - Number of material default values does not match MCS in header.\n";
5865 if (m_nSize == 1 ) {
5866 sprintf(buf,
"Value = %llu (0x016%llx)\n", m_Num[0], m_Num[0]);
5867 sDescription += buf;
5871 sDescription.reserve(sDescription.size() + m_nSize*79);
5873 for (i=0; i<m_nSize; i++) {
5874 sprintf(buf,
"Value = %llu (0x016%llx)\n", m_Num[i], m_Num[i]);
5875 sDescription += buf;
5894template <
class T, icTagTypeSignature Tsig>
5900 m_Num = (T*)
icRealloc(m_Num, nSize*
sizeof(T));
5907 if (bZeroNew && m_nSize < nSize) {
5908 memset(&m_Num[m_nSize], 0, (nSize-m_nSize)*
sizeof(T));
5926template <
class T, icTagTypeSignature Tsig>
5929 if (nVectorSize+nStart >m_nSize)
5936 for (i=0; i<m_nSize; i++) {
5941 for (i=0; i<m_nSize; i++) {