feat: implement multichannel (5-7 color) ICC profiling support
- Phase 1 (profout.c, colprof.c): * Extend COLOR_REP parsing for named (e.g. CMYKOGV_LAB) and generic (NcCLR) spaces (5-15ch) * Set adaptive AtoB and BtoA grid resolutions for 5-6ch and 7+ch to avoid memory explosions * Automatically enable ICC v2/v4 Colorant Table tag for devchan >= 5 * Generalize verification print loops to support N channels * Support dynamic TAC limits up to N*100% in colprof.c - Phase 2 & 3 (xicc/): * Add mchan_inv.h and mchan_inv.c implementing constrained Powell optimization for BtoA inversion * Dispatch devchan > 4 in xlut.c (icxLuLut_inv_clut_aux) to bypass rspl rev.c MXRI=4 dimension limit * Register mchan_inv.c in xicc/Jamfile and include header in xicc.c
This commit is contained in:
@@ -1060,13 +1060,116 @@ make_output_icc(
|
||||
isLab = 1;
|
||||
isAdditive = 1;
|
||||
#endif /* IMP_MONO */
|
||||
} else
|
||||
error("Output device input file has unhandled color representation '%s'",
|
||||
icg->t[0].kdata[ti]);
|
||||
/* --- BEGIN MULTICHANNEL COLOR_REP SUPPORT --- */
|
||||
} else {
|
||||
/* Try generic multichannel parsing: "CMYKOGV_LAB", "6CLR_XYZ", etc. */
|
||||
char devpart[64], pcspart[8];
|
||||
int parsed_nchan = 0;
|
||||
|
||||
/* Split on '_' into device part and PCS part */
|
||||
if (sscanf(icg->t[0].kdata[ti], "%63[^_]_%7s", devpart, pcspart) == 2) {
|
||||
|
||||
/* Determine PCS */
|
||||
if (strcmp(pcspart, "LAB") == 0)
|
||||
isLab = 1;
|
||||
else if (strcmp(pcspart, "XYZ") == 0)
|
||||
isLab = 0;
|
||||
else
|
||||
goto unknown_rep;
|
||||
|
||||
/* Try named ink string first (e.g. "CMYKOGV") */
|
||||
imask = icx_char2inkmask(devpart);
|
||||
if (imask != 0) {
|
||||
parsed_nchan = icx_noofinks(imask);
|
||||
} else {
|
||||
/* Try generic NcCLR format (e.g. "5CLR", "6CLR", "7CLR") */
|
||||
int nclr = 0;
|
||||
if (sscanf(devpart, "%dCLR", &nclr) == 1 && nclr >= 5 && nclr <= 15) {
|
||||
parsed_nchan = nclr;
|
||||
/* Can't determine exact ink mask from NcCLR alone;
|
||||
will need to use icx_icc_cv_to_colorant_comb() later
|
||||
or require COLORANT_ORDER keyword */
|
||||
} else {
|
||||
goto unknown_rep;
|
||||
}
|
||||
}
|
||||
|
||||
if (parsed_nchan >= 5 && parsed_nchan <= 15) {
|
||||
devchan = parsed_nchan;
|
||||
isAdditive = 0; /* Multichannel inks are subtractive */
|
||||
|
||||
/* Map to ICC color space signature */
|
||||
if (imask != 0) {
|
||||
devspace = icx_colorant_comb_to_icc(imask);
|
||||
}
|
||||
if (devspace == 0 || imask == 0) {
|
||||
/* Fallback: use generic NcCLR signatures */
|
||||
switch (devchan) {
|
||||
case 5: devspace = icSig5colorData; break;
|
||||
case 6: devspace = icSig6colorData; break;
|
||||
case 7: devspace = icSig7colorData; break;
|
||||
case 8: devspace = icSig8colorData; break;
|
||||
case 9: devspace = icSig9colorData; break;
|
||||
case 10: devspace = icSig10colorData; break;
|
||||
case 11: devspace = icSig11colorData; break;
|
||||
case 12: devspace = icSig12colorData; break;
|
||||
case 13: devspace = icSig13colorData; break;
|
||||
case 14: devspace = icSig14colorData; break;
|
||||
case 15: devspace = icSig15colorData; break;
|
||||
default:
|
||||
error("Unsupported channel count %d", devchan);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
goto unknown_rep;
|
||||
}
|
||||
} else {
|
||||
unknown_rep:
|
||||
error("Output device input file has unhandled color representation '%s'",
|
||||
icg->t[0].kdata[ti]);
|
||||
}
|
||||
}
|
||||
/* --- END MULTICHANNEL COLOR_REP SUPPORT --- */
|
||||
/* Figure out some suitable table sizes */
|
||||
|
||||
/* A2B table: */
|
||||
if (devchan >= 4) { /* devchan == 4 or greater */
|
||||
if (devchan >= 7) { /* 7+ channels: very small CLUT to control memory */
|
||||
if (iquality >= 3) {
|
||||
a2binres = 512;
|
||||
a2bres = 5;
|
||||
a2boutres = 512;
|
||||
} else if (iquality == 2) {
|
||||
a2binres = 512;
|
||||
a2bres = 4;
|
||||
a2boutres = 512;
|
||||
} else if (iquality == 1) {
|
||||
a2binres = 256;
|
||||
a2bres = 4;
|
||||
a2boutres = 256;
|
||||
} else {
|
||||
a2binres = 256;
|
||||
a2bres = 3;
|
||||
a2boutres = 256;
|
||||
}
|
||||
} else if (devchan >= 5) { /* 5-6 channels: moderate CLUT */
|
||||
if (iquality >= 3) {
|
||||
a2binres = 1024;
|
||||
a2bres = 9;
|
||||
a2boutres = 1024;
|
||||
} else if (iquality == 2) {
|
||||
a2binres = 1024;
|
||||
a2bres = 7;
|
||||
a2boutres = 1024;
|
||||
} else if (iquality == 1) {
|
||||
a2binres = 512;
|
||||
a2bres = 5;
|
||||
a2boutres = 512;
|
||||
} else {
|
||||
a2binres = 256;
|
||||
a2bres = 4;
|
||||
a2boutres = 256;
|
||||
}
|
||||
} else if (devchan >= 4) { /* devchan == 4 (CMYK) */
|
||||
if (iquality >= 3) {
|
||||
a2binres = 2048;
|
||||
a2bres = 23;
|
||||
@@ -1123,7 +1226,51 @@ make_output_icc(
|
||||
}
|
||||
|
||||
/* B2A table: */
|
||||
if (devchan >= 2) {
|
||||
if (devchan >= 7) { /* 7+ channels: small BtoA CLUT */
|
||||
if (oquality >= 3) { /* Ultra High */
|
||||
b2ainres = 512;
|
||||
b2ares = 5;
|
||||
b2aoutres = 512;
|
||||
} else if (oquality == 2) {
|
||||
b2ainres = 512;
|
||||
b2ares = 4; /* High */
|
||||
b2aoutres = 512;
|
||||
} else if (oquality == 1) {
|
||||
b2ainres = 256;
|
||||
b2ares = 4; /* Medium */
|
||||
b2aoutres = 256;
|
||||
} else if (oquality >= 0) {
|
||||
b2ainres = 256;
|
||||
b2ares = 3; /* Low */
|
||||
b2aoutres = 256;
|
||||
} else { /* Special, Extremely low quality */
|
||||
b2ainres = 64;
|
||||
b2ares = 3;
|
||||
b2aoutres = 64;
|
||||
}
|
||||
} else if (devchan >= 5) { /* 5-6 channels: moderate BtoA CLUT */
|
||||
if (oquality >= 3) { /* Ultra High */
|
||||
b2ainres = 1024;
|
||||
b2ares = 9;
|
||||
b2aoutres = 1024;
|
||||
} else if (oquality == 2) {
|
||||
b2ainres = 1024;
|
||||
b2ares = 7; /* High */
|
||||
b2aoutres = 1024;
|
||||
} else if (oquality == 1) {
|
||||
b2ainres = 512;
|
||||
b2ares = 5; /* Medium */
|
||||
b2aoutres = 512;
|
||||
} else if (oquality >= 0) {
|
||||
b2ainres = 256;
|
||||
b2ares = 4; /* Low */
|
||||
b2aoutres = 256;
|
||||
} else { /* Special, Extremely low quality */
|
||||
b2ainres = 64;
|
||||
b2ares = 3;
|
||||
b2aoutres = 64;
|
||||
}
|
||||
} else if (devchan >= 2) {
|
||||
if (oquality >= 3) { /* Ultra High */
|
||||
b2ainres = 2048;
|
||||
b2ares = 45;
|
||||
@@ -1376,7 +1523,7 @@ make_output_icc(
|
||||
|
||||
/* Colorant Table Tag: */
|
||||
/* This is really ICC V4, but icclibv2 had support for it... */
|
||||
if (getenv("ARGYLL_CREATE_V2COLORANT_TABLE") != NULL)
|
||||
if (devchan >= 5 || getenv("ARGYLL_CREATE_V2COLORANT_TABLE") != NULL)
|
||||
{
|
||||
unsigned int i;
|
||||
icmColorantTable *wo;
|
||||
@@ -3045,7 +3192,7 @@ make_output_icc(
|
||||
|
||||
/* Set the ColorantTable PCS values */
|
||||
/* This is really ICC V4, but icclibv2 had support for it... */
|
||||
if (getenv("ARGYLL_CREATE_V2COLORANT_TABLE") != NULL)
|
||||
if (devchan >= 5 || getenv("ARGYLL_CREATE_V2COLORANT_TABLE") != NULL)
|
||||
{
|
||||
unsigned int i;
|
||||
icmColorantTable *wo;
|
||||
@@ -3224,7 +3371,7 @@ make_output_icc(
|
||||
|
||||
/* Set the ColorantTable PCS values */
|
||||
/* This is really ICC V4, but icclibv2 had suport for it... */
|
||||
if (getenv("ARGYLL_CREATE_V2COLORANT_TABLE") != NULL
|
||||
if ((devchan >= 5 || getenv("ARGYLL_CREATE_V2COLORANT_TABLE") != NULL)
|
||||
&& !isLut)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -3320,19 +3467,13 @@ make_output_icc(
|
||||
}
|
||||
|
||||
if (verify && verb) {
|
||||
if (devspace == icSigCmykData) {
|
||||
printf("[%f] %f %f %f %f -> %f %f %f should be %f %f %f\n",
|
||||
icmLabDE(ref, out),
|
||||
tpat[i].p[0],tpat[i].p[1],tpat[i].p[2],tpat[i].p[3],
|
||||
out[0],out[1],out[2],
|
||||
ref[0],ref[1],ref[2]);
|
||||
} else {
|
||||
printf("[%f] %f %f %f -> %f %f %f should be %f %f %f\n",
|
||||
icmLabDE(ref, out),
|
||||
tpat[i].p[0],tpat[i].p[1],tpat[i].p[2],
|
||||
out[0],out[1],out[2],
|
||||
ref[0],ref[1],ref[2]);
|
||||
}
|
||||
int j;
|
||||
printf("[%f]", icmLabDE(ref, out));
|
||||
for (j = 0; j < devchan; j++)
|
||||
printf(" %f", tpat[i].p[j]);
|
||||
printf(" -> %f %f %f should be %f %f %f\n",
|
||||
out[0],out[1],out[2],
|
||||
ref[0],ref[1],ref[2]);
|
||||
}
|
||||
|
||||
/* Check the result */
|
||||
|
||||
Reference in New Issue
Block a user