02428 {
02429         
icHeader                                profHeader;
02430         
CMLutParam                              aDoNDimTableData;
02431         
DoMatrixForCubeStruct   aDoMatrixForCubeStruct;
02432         
CMCalcParam                     calcParam;
02433                         
02434         
CMError                         err = 
noErr;
02435         
OSErr                           aOSerr = 
noErr;
02436         
CUBE_DATA_TYPE          inputBuffer      = 
nil;
02437         
CUBE_DATA_TYPE          outputBuffer = 
nil;
02438 
02439         
SINT32                          loop;
02440         
SINT32                          theSize;
02441         
SINT32                          theElutSize;
02442         
SINT32                          theAlutSize;
02443         
SINT32                          theCubeSize;
02444         
SINT32                          theExtraSize=1;
02445         
SINT32                          theCubePixelCount;
02446         
UINT16                          profLoop;
02447         
SINT32                          savedGridPoints;
02448         
SINT32                          gridBits;
02449         
SINT32                          gridPointsCube;
02450         
Boolean                         SavedoCreate_16bit_XLut;
02451         
Boolean                         SavedoCreate_16bit_ALut;
02452         
void                                    *SaveoutputLut;
02453         
long                            SaveoutputLutEntryCount;
02454         
long                            SaveoutputLutWordSize;
02455         
02456         
UINT8                           bIsLabConnection = 0;
02457         
02458         
SINT32                          numOfElutsCube;
02459 
02460         
Boolean                         doSaveElut              = 
TRUE;
02461         
Boolean                         skipCombi               = 
FALSE;
02462         
Boolean                         pcsConversion   = 
FALSE;
02463         
Boolean                         useOutputBuffer;
02464         
LHCombiData                     theCombiData;
02465         
CMLutParam                      theLutData;     
02466         
SINT32                          theBufferByteCount;
02467         
UINT16                          aUINT16;
02468         
UINT16                          *wordPtr   = 
nil;
02469         
UINT8                           *xlutPtr   = 
nil;
02470 
#ifdef DoLabSpecial
02471 
        UINT32                          aFac;
02472         
UINT32                          i;
02473 
#endif
02474 
02475 
#ifdef WRITE_LUTS
02476 
        Str255                          fileString;
02477 
#endif
02478 
#ifdef DEBUG_OUTPUT
02479 
        Str255                          lutString;
02480 
#endif
02481 
        LH_START_PROC(
"CreateCombi")
02482 
02483         theBufferByteCount = 2;
02484         SetMem(&theCombiData,   sizeof(
LHCombiData), 0);
02485         SetMem(&theLutData,     sizeof(
CMLutParam),      0);
02486         
02487         theCombiData.amIPCS = FALSE;                    
02488         if ( modelingData->hasNamedColorProf == NamedColorProfileAtBegin ){
02489                 theCombiData.amIPCS = 
TRUE;
02490         }
02491         
if (newProfileSet->
count == 1)
02492                 skipCombi = 
TRUE;
02493         
02494         err = 
CMGetProfileHeader(profileSet->
profileSet[0], (
CMCoreProfileHeader *)&profHeader);
02495         
if (err)
02496                 
goto CleanupAndExit;
02497         modelingData->precision = (
SINT16)((profHeader.
flags & 
kQualityMask)>>16);
02498         
02499 
#ifdef RenderInt
02500 
        if( modelingData-> 
dwFlags != 0xffffffff ){
02501                 modelingData->precision = (
short)( modelingData->dwFlags & 0x0ffff);
02502         }
02503 
#endif
02504 
        if ( modelingData->precision >= 
cmBestMode )            
02505         {
02506                 theCombiData.
doCreate_16bit_Combi = 
TRUE;
02507                 modelingData->precision = 
cmBestMode;
02508         }
02509         
else
02510         {
02511       theCombiData.
doCreate_16bit_Combi = 
FALSE;
02512         }
02513 
#ifdef DEBUG_OUTPUT
02514 
        if ( DebugCheck(kThisFile, kDebugMiscInfo) )
02515                 
DebugPrint(
"  CMMModelHandle->precision = %d doCreate_16bit_Combi=%d\n",modelingData->precision,theCombiData.
doCreate_16bit_Combi);
02516 
#endif
02517 
        
02518         
switch (modelingData->precision)
02519         {
02520                 
case cmNormalMode:
02521                         
if (createGamutLut)
02522                                 theCubePixelCount = 87382;
02523                         
else
02524                                 theCubePixelCount = 87382;
02525                                 
if( modelingData->lookup )theCubePixelCount = 87382;
02526                                 
break;
02527                 
case cmDraftMode:
02528                         
if (createGamutLut)
02529                                 theCubePixelCount = 5462;
02530                         
else
02531                                 theCubePixelCount = 5462;               
02532                         
break;
02533                 
case cmBestMode:
02534                         
if (createGamutLut)
02535                                 theCubePixelCount = 87382;
02536                         
else
02537                                 theCubePixelCount = 87382;   
02538                         
break;
02539         }
02540         theCubeSize = theCubePixelCount * 3;
02541         theCombiData.
precision                   = modelingData->precision;
02542         theCombiData.
maxProfileCount     = newProfileSet->
count-1;
02543         theCombiData.
doCreateLinkProfile = (modelingData->currentCall == 
kCMMNewLinkProfile);
02544         
switch ( modelingData->firstColorSpace )
02545         {
02546                 
case icSigXYZData:
02547                 
case icSigLabData:
02548                 
case icSigLuvData:
02549                 
case icSigYxyData:
02550                 
case icSigRgbData:
02551                 
case icSigHsvData:
02552                 
case icSigHlsData:
02553                 
case icSigCmyData:
02554 
#ifdef PI_Application_h
02555 
                case icSigYCbCrData:
02556                 
case icSigMCH3Data:
02557                 
case icSigNamedData:
02558 
#endif
02559 
                        err = 
CalcGridPoints4Cube ( theCubeSize, 3, &theCombiData.
gridPointsCube, &gridBits );          
02560                         
break;
02561                 
case icSigGrayData:
02562                         theCubeSize = 255 ;
02563                         err = 
CalcGridPoints4Cube ( theCubeSize, 1, &theCombiData.
gridPointsCube, &gridBits );          
02564                         
break;
02565                 
case icSigCmykData:
02566                 
case icSigMCH4Data:
02567                         err = 
CalcGridPoints4Cube ( theCubeSize, 4, &theCombiData.
gridPointsCube, &gridBits );          
02568                         
break;
02569                 
case icSigMCH2Data:
02570                         err = 
CalcGridPoints4Cube ( theCubeSize, 2, &theCombiData.
gridPointsCube, &gridBits );          
02571                         
break;
02572                 
case icSigMCH5Data:
02573                         err = 
CalcGridPoints4Cube ( theCubeSize, 5, &theCombiData.
gridPointsCube, &gridBits );          
02574                         
break;
02575                 
case icSigMCH6Data:
02576                         err = 
CalcGridPoints4Cube ( theCubeSize, 6, &theCombiData.
gridPointsCube, &gridBits );          
02577                         
break;
02578                 
case icSigMCH7Data:
02579                         err = 
CalcGridPoints4Cube ( theCubeSize, 7, &theCombiData.
gridPointsCube, &gridBits );          
02580                         
break;
02581                 
case icSigMCH8Data:
02582                         err = 
CalcGridPoints4Cube ( theCubeSize, 8, &theCombiData.
gridPointsCube, &gridBits );          
02583                         
break;
02584         }
02585 
02586         bIsLabConnection = 0;
02587         
if( profHeader.
pcs == 
icSigXYZData ){
02588                 
for ( profLoop = 0; profLoop < newProfileSet->
count; profLoop++ ){
02589                         
if( newProfileSet->
prof[profLoop].
profileSet == 0 ){
02590                                 bIsLabConnection |= 1;
02591                         }
02592                 }
02593         }
02594         err = 
CMGetProfileHeader(profileSet->
profileSet[profileSet->
count-1], (
CMCoreProfileHeader *)&profHeader);
02595         
if (err)
02596                 
goto CleanupAndExit;
02597         
if( profHeader.
pcs == 
icSigXYZData ){
02598                 
for ( profLoop = 0; profLoop < newProfileSet->
count; profLoop++ ){
02599                         
if( newProfileSet->
prof[profLoop].
profileSet == 0 && !createGamutLut ){
02600                                 bIsLabConnection |=2;
02601                         }
02602                 }
02603         }
02604         
02605         
if( modelingData->hasNamedColorProf == 
NamedColorProfileAtBegin ){
02606                 bIsLabConnection |=1;
02607                 theCombiData.
doCreate_16bit_Combi = 
TRUE;
02608         }
02609                 
02610         
if( modelingData->hasNamedColorProf == 
NamedColorProfileAtEnd ){
02611                 bIsLabConnection |=2;
02612                 theCombiData.
doCreate_16bit_Combi = 
TRUE;
02613         }
02614                 
02615         
02616 
02617 
02618         
for ( profLoop = 0; profLoop < newProfileSet->
count; profLoop++ )
02619         {
02620 
#ifdef DEBUG_OUTPUT
02621 
                if ( DebugCheck(kThisFile, kDebugMiscInfo) )
02622                         
DebugPrint(
"  <ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ Processing profile #%d ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ>\n",profLoop);
02623 
#endif
02624 
                theCombiData.
profLoop = (
long)profLoop;
02625                 
if ( theCombiData.
doCreateLinkProfile )
02626                 {
02627                         theCombiData.
doCreate_16bit_ELut = 
TRUE;
02628             theCombiData.
doCreate_16bit_XLut = 
TRUE; 
02629                         theCombiData.
doCreate_16bit_ALut = 
TRUE;
02630                 } 
else
02631                 {
02632                         theCombiData.
doCreate_16bit_ELut = ( profLoop != 0 );
02633             theCombiData.
doCreate_16bit_XLut = theCombiData.
doCreate_16bit_Combi;       
02634                         theCombiData.
doCreate_16bit_ALut = ( profLoop != newProfileSet->
count-1 );
02635                 }
02636                 
if (newProfileSet->
prof[profLoop].
profileSet)
02637                 {
02638                         theCombiData.
theProfile = newProfileSet->
prof[profLoop].
profileSet;
02639                         err = 
CMGetProfileHeader(theCombiData.
theProfile, (
CMCoreProfileHeader *)&profHeader);
02640                         
if (err)
02641                                 
goto CleanupAndExit;
02642                         theCombiData.
profileClass                       = profHeader.
deviceClass;
02643                         theCombiData.
dataColorSpace             = profHeader.
colorSpace;
02644                         theCombiData.
profileConnectionSpace     = profHeader.
pcs;
02645                         theCombiData.
renderingIntent            = newProfileSet->
prof[profLoop].
renderingIntent;
02646                         pcsConversion = 
FALSE;
02647                 }
02648                 
else{
02649                         pcsConversion = 
TRUE;
02650                 }
02651                 
if ( (err == 
noErr) || pcsConversion ){
02652                         
02653                         theLutData.
inputLut     = 
DISPOSE_IF_DATA(theLutData.
inputLut);
02654                         theLutData.
outputLut    = 
DISPOSE_IF_DATA(theLutData.
outputLut);
02655                         theLutData.
colorLut     = 
DISPOSE_IF_DATA(theLutData.
colorLut);
02656                         theLutData.
matrixMFT    = 
DisposeIfPtr(theLutData.
matrixMFT);
02657                         theLutData.
matrixTRC    = 
DisposeIfPtr(theLutData.
matrixTRC);
02658                         
02659                         
if (pcsConversion)
02660                         {
02661                                 
02662 
02663 
02664                                 
if (inputBuffer == 
nil)
02665                                 {
02666                                         theLutData.
colorLutInDim = 3;
02667 
#ifdef DoLabSpecial
02668 
                                        if( modelingData->firstColorSpace == 
icSigLabData || modelingData->firstColorSpace == 
icSigLuvData ){
02669                                                 err = 
MakeSpecialCube16(theLutData.
colorLutInDim, &theCubeSize, &theLutData.
colorLut, &gridBits, &theExtraSize );
02670                                         }
02671                                         
else
02672 
#endif
02673 
                                        err = 
MakeCube16(theLutData.
colorLutInDim, &theCubeSize, &theLutData.
colorLut, &gridBits, &theExtraSize );
02674 
#ifdef DEBUG_OUTPUT
02675 
                                        if ( DebugCheck(kThisFile, kDebugMiscInfo) )
02676                                                 
DebugPrint(
"  MakeCube16 -> '%d' bits    cubeSize = %d\n",gridBits, theCubeSize);
02677 
#endif
02678 
                                        if (err)
02679                                                 
goto CleanupAndExit;
02680                                         theCubePixelCount = theCubeSize / theLutData.
colorLutInDim;
02681                                         numOfElutsCube = theLutData.
colorLutInDim;
02682                                         gridPointsCube = 1<<gridBits;
02683                                         savedGridPoints = gridPointsCube;
02684                                         
if( profLoop == 0 ){
02685                                                 theLutData.
inputLutEntryCount = 1<<
adr_breite_elut;
02686                                                 
if( theCombiData.
doCreate_16bit_ELut ) theLutData.
inputLutWordSize = 
VAL_USED_BITS;
02687                                                 
else  theLutData.
inputLutWordSize = 
bit_breite_elut;
02688                                                 theLutData.
colorLutGridPoints = gridPointsCube; 
02689                                         }
02690 
02691                                 }
02692                                 
else{
02693                                         theLutData.
colorLut = inputBuffer;
02694                                         inputBuffer = 
nil;
02695                                 }
02696                                 
02697                                 
LOCK_DATA(theLutData.
colorLut);
02698 
#ifdef DEBUG_OUTPUT
02699 
                                ShowCube16( profLoop, 
"Lab<->XYZ", createGamutLut, (UINT16 *)
DATA_2_PTR(theLutData.
colorLut), gridPointsCube, theLutData.
colorLutInDim, 3,VAL_USED_BITS );
02700 
#endif
02701 
                                
02702 
02703 
02704 
02705 
02706 
02707 
02708 
02709 
02710 
02711 
02712 
02713 
02714 
02715 
02716                                 
if ( newProfileSet->
prof[profLoop].
pcsConversionMode == 
kDoLab2XYZ )
02717                                 {
02718 
#ifdef DEBUG_OUTPUT
02719 
                                        if ( DebugCheck(kThisFile, kDebugMiscInfo) )
02720                                                 
DebugPrint(
"  doing a PCS conversion:  Lab -> XYZ\n");
02721 
#endif
02722 
                                        Lab2XYZ_forCube16((UINT16*)
DATA_2_PTR(theLutData.
colorLut), theCubePixelCount);
02723                                 }
02724                                 
else if ( newProfileSet->
prof[profLoop].
pcsConversionMode == 
kDoXYZ2Lab )
02725                                 {
02726 
#ifdef DEBUG_OUTPUT
02727 
                                        if ( DebugCheck(kThisFile, kDebugMiscInfo) )
02728                                                 
DebugPrint(
"  doing a PCS conversion:  XYZ -> Lab\n");
02729 
#endif
02730 
                                        XYZ2Lab_forCube16((UINT16*)
DATA_2_PTR(theLutData.
colorLut), theCubePixelCount);
02731                                 }
02732 
#ifdef DEBUG_OUTPUT
02733 
                                ShowCube16( profLoop, 
"after Lab<->XYZ", createGamutLut, (UINT16 *)
DATA_2_PTR(theLutData.
colorLut), gridPointsCube, theLutData.
colorLutInDim, 3, VAL_USED_BITS );
02734 
#endif
02735 
                                UNLOCK_DATA(theLutData.
colorLut);
02736                                 skipCombi = 
TRUE;
02737                                 theLutData.
colorLutInDim = 
kNumOfLab_XYZchannels;
02738                                 theLutData.
colorLutOutDim = 
kNumOfLab_XYZchannels;
02739                         } 
else
02740                         {
02741                                 
02742 
02743 
02744                                 theCombiData.
doCreateGamutLut = createGamutLut && (profLoop == newProfileSet->
count - 1);
02745                                 theCombiData.
usePreviewTag        = (
UINT8)newProfileSet->
prof[profLoop].
usePreviewTag;                         
02746                                 
02747                                 
02748 
02749 
02750 
02751                                 
if( bIsLabConnection & 1 ){
02752                                         
if ( theCombiData.
maxProfileCount > 0 ){
02753                                                 theCombiData.
maxProfileCount = 0;
02754                                                 SavedoCreate_16bit_XLut = theCombiData.
doCreate_16bit_XLut;
02755                                                 theCombiData.
doCreate_16bit_XLut = 
TRUE;
02756                                         }
02757                                 }
02758                                 
if( bIsLabConnection & 2 ){
02759                                         SavedoCreate_16bit_ALut = theCombiData.
doCreate_16bit_ALut;
02760                                         theCombiData.
doCreate_16bit_ALut = 
TRUE;
02761                                 }
02762                                 err = 
ExtractAllLuts (&theLutData, &theCombiData);
02763                                 
if( newProfileSet->
count == 1 ){
02764                                         gridPointsCube = theLutData.
colorLutGridPoints;
02765                                 }
02766 
02767                                 
if( bIsLabConnection & 1 ){
02768                                         theCombiData.
maxProfileCount = newProfileSet->
count-1;
02769                                         
if ( theCombiData.
maxProfileCount > 0 ){
02770                                                 theCombiData.
doCreate_16bit_XLut = SavedoCreate_16bit_XLut;
02771                                         }
02772                                 }
02773                                 
if( bIsLabConnection & 2 ){
02774                                         theCombiData.
doCreate_16bit_ALut = SavedoCreate_16bit_ALut;
02775                                 }
02776                                 
02777                                 
if (err)
02778                                         
goto CleanupAndExit;
02779                                 
if ( (theLutData.
colorLutInDim == 0) || (theLutData.
colorLutOutDim == 0))
02780                                 {
02781                                         err = 
cmProfileError;
02782                                         
goto CleanupAndExit;
02783                                 }
02784                         }
02785 
#ifdef DEBUG_OUTPUT
02786 
                        if ( DebugCheck(kThisFile, kDebugEXASizeInfo) )
02787                         {
02788                                 
if (theLutData.
inputLut)
02789                                         
DebugPrint(
"  Elut = %6d\n", (theLutData.
inputLutEntryCount*theLutData.
colorLutInDim*(theLutData.
inputLutWordSize>8?2:1)));
02790                                 
if (theLutData.
colorLut)
02791                                         
DebugPrint(
"  Xlut colorLutGridPoints = %6d\n       colorLutInDim      = %6d\n       colorLutOutDim     = %6d\n       colorLutWordSize   = %6d\n",
02792                                                                 theLutData.
colorLutGridPoints,theLutData.
colorLutInDim,theLutData.
colorLutOutDim,theLutData.
colorLutWordSize);
02793                                 
if (theLutData.
outputLut)
02794                                         
DebugPrint(
"  Alut = %6d ", (theLutData.
outputLutEntryCount*theLutData.
colorLutOutDim*(theLutData.
outputLutWordSize>8?2:1)));
02795                                 
DebugPrint(
"\n");
02796                         }
02797 
#endif
02798 
                        if (theLutData.
matrixMFT)
02799                                 skipCombi = 
FALSE;
02800                         
02801 
02802 
02803                         
if (doSaveElut) 
02804                         {
02805                                 
if ( skipCombi )
02806                                         savedGridPoints = theLutData.
colorLutGridPoints;
02807                                 
else
02808                                 {
02809                                         
if (theLutData.
colorLutInDim == 1)
02810                                         {
02811                                                 theCubeSize = 255 ;
02812                                         }
02813                                         
02814 
#ifdef DoLabSpecial
02815 
                                        if( modelingData->firstColorSpace == 
icSigLabData || modelingData->firstColorSpace == 
icSigLuvData ){
02816                                                 err = 
MakeSpecialCube16(theLutData.
colorLutInDim, &theCubeSize, &inputBuffer, &gridBits, &theExtraSize );
02817                                         }
02818                                         
else
02819 
#endif
02820 
                                        err = 
MakeCube16(theLutData.
colorLutInDim, &theCubeSize, &inputBuffer, &gridBits, &theExtraSize);
02821 
#ifdef DEBUG_OUTPUT
02822 
                                        if ( DebugCheck(kThisFile, kDebugMiscInfo) )
02823                                                 
DebugPrint(
"  MakeCube16 -> '%d' bits    cubeSize = %d\n",gridBits, theCubeSize);
02824 
#endif
02825 
                                        if (err)
02826                                                 
goto CleanupAndExit;
02827                                         theCubePixelCount = theCubeSize / theLutData.
colorLutInDim;
02828                                         numOfElutsCube = theLutData.
colorLutInDim;
02829                                         gridPointsCube = 1<<gridBits;
02830                                         savedGridPoints = gridPointsCube;
02831                                 }
02832                                 
02833                                                       
02834                                 theSize = theLutData.
inputLutEntryCount * theLutData.
colorLutInDim;                             
02835                                 
if ( theLutData.
inputLutWordSize > 8 )
02836                                         theSize *= 2;
02837                                 
02838                                 
if( bIsLabConnection & 1 ){
02839                                         
02840                                         finalLutData->
inputLut = 
ALLOC_DATA(theSize+2, &aOSerr);
02841                                         err = aOSerr;
02842                                         
if (err)
02843                                                 
goto CleanupAndExit;
02844                                         
02845                                         
02846                                         theElutSize = theSize / theLutData.
colorLutInDim;
02847                                         
LOCK_DATA(finalLutData->
inputLut);
02848                                         
if( theCombiData.
doCreate_16bit_ELut || theCombiData.
doCreate_16bit_Combi){
02849                                                 
CreateLinearElut16 ( (Ptr)
DATA_2_PTR(finalLutData->
inputLut), theElutSize/ sizeof (UINT16), gridPointsCube, 0 );
02850                                                 finalLutData->
inputLutWordSize = 
VAL_USED_BITS;
02851                                         }
02852                                         
else{
02853                                                 
CreateLinearElut ( (Ptr)
DATA_2_PTR(finalLutData->
inputLut), theElutSize/ sizeof (UINT16), gridPointsCube, 0 );
02854                                                 finalLutData->
inputLutWordSize = 
bit_breite_elut;
02855                                         }
02856                                         
for (loop = 0; loop < theLutData.
colorLutInDim; loop++)
02857                                                 
BlockMoveData(
DATA_2_PTR(finalLutData->
inputLut), (Ptr)
DATA_2_PTR(finalLutData->
inputLut) + loop * theElutSize, theElutSize);
02858                                         finalLutData->
inputLutEntryCount = theElutSize/
sizeof(
UINT16);
02859                                         
UNLOCK_DATA(finalLutData->
inputLut);
02860                                         finalLutData->
colorLutInDim              = theLutData.
colorLutInDim;
02861                                         bIsLabConnection &= ~1;
02862                                 }
02863                                 
else{
02864                                         finalLutData->
inputLutWordSize   = theLutData.
inputLutWordSize;
02865                                         finalLutData->
inputLut                   = theLutData.
inputLut;
02866                                         finalLutData->
inputLutEntryCount = theLutData.
inputLutEntryCount;
02867                                         finalLutData->
colorLutInDim              = theLutData.
colorLutInDim;
02868                                         
02869                                         theLutData.
inputLut = 
ALLOC_DATA(theSize+2, &aOSerr);
02870                                         err = aOSerr;
02871                                         
if (err)
02872                                                 
goto CleanupAndExit;
02873                                         
02874                                         
02875                                         theElutSize = theSize / theLutData.
colorLutInDim;
02876                                         
LOCK_DATA(theLutData.
inputLut);
02877                                         
CreateLinearElut16 ( (Ptr)
DATA_2_PTR(theLutData.
inputLut), theElutSize/ sizeof (UINT16), theLutData.
colorLutGridPoints, 0);
02878                                         
for (loop = 0; loop < theLutData.
colorLutInDim; loop++)
02879                                                 
BlockMoveData(
DATA_2_PTR(theLutData.
inputLut), (Ptr)
DATA_2_PTR(theLutData.
inputLut) + loop * theElutSize, theElutSize);
02880                                         theLutData.
inputLutEntryCount = theElutSize/
sizeof(
UINT16);
02881                                         theLutData.
inputLutWordSize = 
VAL_USED_BITS;
02882                                         
UNLOCK_DATA(theLutData.
inputLut);
02883                                 }
02884                                 doSaveElut = 
FALSE;
02885 
#ifdef DoLabSpecial
02886 
                                if( (modelingData->firstColorSpace == 
icSigLabData || modelingData->firstColorSpace == 
icSigLuvData) ){
02887                                         
LOCK_DATA(finalLutData->
inputLut);
02888                                         wordPtr = (
UINT16 *)
DATA_2_PTR( finalLutData->
inputLut );
02889                                         aFac = (((1<<15)*((
UINT32)finalLutData->
inputLutEntryCount-1)*(
UINT32)gridPointsCube + finalLutData->
inputLutEntryCount/2)/
02890                                                         (
UINT32)finalLutData->
inputLutEntryCount + gridPointsCube/2)/((
UINT32)gridPointsCube-1);
02891                                         i = finalLutData->
inputLutEntryCount/2 - 1;
02892                                         
for( aUINT16 = 0; aUINT16 < (
UINT16)finalLutData->
colorLutInDim; aUINT16++){
02893                                                 
for( loop = 0; loop <= (
SINT32)(i+1); loop++){
02894                                                         *wordPtr++ = (
UINT16)((*wordPtr * aFac + (1<<(15-1)) )>>15);
02895                                                 }
02896 
02897                                                 
for( loop = 1; loop <= (
SINT32)i; loop++){
02898                                                         *wordPtr++ = (
UINT16)((*wordPtr * ((aFac *( i - loop ) + (1<<15) * loop + i/2)/i) + (1<<(15-1)) )>>15);
02899                                                 }
02900                                         }
02901                                         
UNLOCK_DATA(finalLutData->
inputLut);
02902                                 }       
02903 
#endif                  
02904 
                        }
02905                         
02906                         
02907 
02908 
02909                         
if (profLoop == newProfileSet->
count - 1)
02910                         {
02911                                 
02912                                 theSize = theLutData.
outputLutEntryCount * theLutData.
colorLutOutDim;                           
02913                                 
if ( theLutData.
outputLutWordSize > 8 )
02914                                         theSize *= 2;
02915                                 
if( bIsLabConnection & 2 ){
02916                                         SaveoutputLut = theLutData.
outputLut;
02917                                         SaveoutputLutEntryCount = theLutData.
outputLutEntryCount;
02918                                         SaveoutputLutWordSize = theLutData.
outputLutWordSize;
02919                                 }
02920                                 
else{
02921                                         finalLutData->
outputLut = theLutData.
outputLut;
02922                                         finalLutData->
outputLutEntryCount = theLutData.
outputLutEntryCount;
02923                                         finalLutData->
outputLutWordSize = theLutData.
outputLutWordSize;
02924                                 }
02925                                 finalLutData->
colorLutOutDim = theLutData.
colorLutOutDim;
02926 
02927                                 theAlutSize = (1<<
adr_breite_alut);
02928                 
if (theCombiData.
doCreate_16bit_ALut || theCombiData.
doCreate_16bit_Combi)
02929                                 {
02930                                         theSize = 
sizeof(
UINT16);;
02931                                         theLutData.
outputLut = 
ALLOC_DATA(theLutData.
colorLutOutDim * theAlutSize * theSize+theSize, &aOSerr);
02932                                         err = aOSerr;
02933                                         
if (err)
02934                                                 
goto CleanupAndExit;
02935                                         
LOCK_DATA(theLutData.
outputLut);
02936                                         
CreateLinearAlut16 ( (UINT16 *)
DATA_2_PTR(theLutData.
outputLut), theAlutSize);
02937                                         
for (loop = 1; loop < theLutData.
colorLutOutDim; loop++)
02938                                                 
BlockMoveData(
DATA_2_PTR(theLutData.
outputLut), (Ptr)
DATA_2_PTR(theLutData.
outputLut) + loop * theAlutSize * 
sizeof(UINT16), theAlutSize * 
sizeof(UINT16));
02939                                         theLutData.
outputLutEntryCount = (
SINT16)theAlutSize;
02940                                         theLutData.
outputLutWordSize = 
VAL_USED_BITS;
02941                                         
UNLOCK_DATA(theLutData.
outputLut);
02942                                 }
02943                                 
else
02944                                 {
02945                                         theSize = 
sizeof(
UINT8);;
02946                                         theLutData.
outputLut = 
ALLOC_DATA(theLutData.
colorLutOutDim * theAlutSize * theSize+theSize, &aOSerr);
02947                                         err = aOSerr;
02948                                         
if (err)
02949                                                 
goto CleanupAndExit;
02950                                         
LOCK_DATA(theLutData.
outputLut);
02951 
02952                                         
CreateLinearAlut( (UINT8*)
DATA_2_PTR(theLutData.
outputLut), theAlutSize );
02953                                         
for (loop = 1; loop < theLutData.
colorLutOutDim; loop++)
02954                                                 
BlockMoveData(
DATA_2_PTR(theLutData.
outputLut), (Ptr)
DATA_2_PTR(theLutData.
outputLut) + loop * theAlutSize, theAlutSize);
02955                                         theLutData.
outputLutEntryCount = theAlutSize;
02956                                         theLutData.
outputLutWordSize = 
bit_breite_alut;
02957                                         
UNLOCK_DATA(theLutData.
outputLut);
02958                                         theBufferByteCount = 1;                 
02959                                 }
02960                                 
if( bIsLabConnection & 2 ){
02961                                         bIsLabConnection &= ~2;
02962                                         finalLutData->
outputLut = theLutData.
outputLut;
02963                                         finalLutData->
outputLutEntryCount = theLutData.
outputLutEntryCount;
02964                                         finalLutData->
outputLutWordSize = theLutData.
outputLutWordSize;
02965                                         theLutData.
outputLut = SaveoutputLut;
02966                                         theLutData.
outputLutEntryCount = SaveoutputLutEntryCount;
02967                                         theLutData.
outputLutWordSize = SaveoutputLutWordSize;
02968                                 }
02969                         }
02970                         
02971                         
if (skipCombi)
02972                         {
02973                                 
02974 
02975 
02976                                 
if (newProfileSet->
count == 1){                 
02977                                         theSize = 1;
02978                                         theExtraSize = 1;
02979                                         
for( loop=0; loop<(theLutData.
colorLutInDim-1); ++loop){        
02980                                                 theSize *=theLutData.
colorLutGridPoints ;
02981                                                 theExtraSize += theSize;
02982                                         }
02983                                         theSize = 1;
02984                                         
for( loop=0; loop<theLutData.
colorLutInDim; ++loop){
02985                                                 theSize *= theLutData.
colorLutGridPoints;
02986                                         }
02987                                         theSize *= theLutData.
colorLutOutDim;
02988 
#ifdef ALLOW_MMX
02989 
                                        theExtraSize++; 
02990 
#endif
02991 
                                        theExtraSize *= theLutData.
colorLutOutDim;
02992                                         inputBuffer = 
DISPOSE_IF_DATA(inputBuffer);
02993                                         
if( theCombiData.
doCreate_16bit_Combi ){
02994                                                 inputBuffer = 
ALLOC_DATA( (theSize+theExtraSize) * 2, &aOSerr );
02995                                                 err = aOSerr;
02996                                                 
if (err)
02997                                                         
goto CleanupAndExit;
02998 
02999                                                 
LOCK_DATA(theLutData.
colorLut);
03000                                                 
LOCK_DATA(inputBuffer);
03001                                                 wordPtr = (
UINT16 *)
DATA_2_PTR( inputBuffer );
03002                                                 xlutPtr = (
UINT8 *)
DATA_2_PTR( theLutData.
colorLut );
03003                                                 
if( theLutData.
colorLutWordSize == 8 ){
03004                                                         
for( loop=0; loop<theSize; ++loop){
03005                                                                 aUINT16 = (
UINT16)xlutPtr[loop];
03006                                                                 wordPtr[loop] = (aUINT16<<8) | aUINT16;
03007                                                         }
03008                                                 }
03009                                                 
else{
03010                                                         
BlockMoveData( xlutPtr, wordPtr, theSize * 2 );
03011                                                 }
03012                                                 
UNLOCK_DATA(theLutData.
colorLut);
03013                                                 
UNLOCK_DATA(inputBuffer);
03014                                                 theLutData.
colorLut = inputBuffer;
03015                                                 theLutData.
colorLutWordSize = 16;
03016                                                 inputBuffer = 0;
03017                                         }
03018                                         
else{
03019                                                 inputBuffer = 
ALLOC_DATA( (theSize+theExtraSize), &aOSerr );
03020                                                 err = aOSerr;
03021                                                 
if (err)
03022                                                         
goto CleanupAndExit;
03023 
03024                                                 
LOCK_DATA(theLutData.
colorLut);
03025                                                 
LOCK_DATA(inputBuffer);
03026                                                 wordPtr = (
UINT16 *)
DATA_2_PTR( inputBuffer );
03027                                                 xlutPtr = (
UINT8 *)
DATA_2_PTR( theLutData.
colorLut );
03028                                                 
BlockMoveData( xlutPtr, wordPtr, theSize );
03029                                                 
UNLOCK_DATA(theLutData.
colorLut);
03030                                                 
UNLOCK_DATA(inputBuffer);
03031                                                 
DISPOSE_IF_DATA( theLutData.
colorLut );
03032                                                 theLutData.
colorLut = inputBuffer;
03033                                                 theLutData.
colorLutWordSize = 8;
03034                                                 inputBuffer = 0;
03035                                         }
03036 
03037 
03038 
03039 
03040 
03041 
03042 
03043 
03044 
03045 
03046 
03047 
03048 
03049 
03050 
03051 
03052 
03053 
03054 
03055 
03056 
03057 
03058 
03059 
03060 
03061 
03062 
03063 
03064                                 }
03065                                 inputBuffer = 
DISPOSE_IF_DATA(inputBuffer);
03066                                 inputBuffer = theLutData.
colorLut;
03067                                 
if (inputBuffer){
03068                                         theCubeSize = theCubePixelCount *  theLutData.
colorLutInDim;
03069                     theCubeSize *= theLutData.
colorLutOutDim;
03070                                 }
03071                                 theLutData.
colorLut = 0;
03072                                 
if ( (profLoop == newProfileSet->
count - 1) && ( ! theCombiData.
doCreate_16bit_ALut  && !theCombiData.
doCreate_16bit_Combi) )
03073                                         theBufferByteCount = 1;                 
03074 
03075                         } 
else
03076                         {
03077                                 
03078 
03079 
03080                                 
if (theLutData.
matrixTRC)
03081                                 {
03082                                         
03083 
03084 
03085                                         
LOCK_DATA(theLutData.
inputLut);
03086                                         
LOCK_DATA(theLutData.
outputLut);
03087                                         
LOCK_DATA(inputBuffer);
03088 
#ifdef DEBUG_OUTPUT
03089 
                                        if ( DebugCheck(kThisFile, kDebugMiscInfo) )
03090                                         {
03091                                                 
DebugPrint(
"¥ matrixTRC: calling DoMatrixForCube16  (gridPointsCube = %d   inputBuffer = %d)\n", gridPointsCube, theCubeSize);
03092                                                 
DebugPrint(
"  theLutData.colorLutGridPoints = %d\n", theLutData.
colorLutGridPoints);
03093                                                 
DebugPrint(
"     %f    %f    %f\n     %f    %f    %f\n     %f    %f    %f\n",
03094                                                                 (*(Matrix2D *)theLutData.
matrixTRC)[0][0],(*(Matrix2D *)theLutData.
matrixTRC)[0][1],(*(Matrix2D *)theLutData.
matrixTRC)[0][2],
03095                                                                 (*(Matrix2D *)theLutData.
matrixTRC)[1][0],(*(Matrix2D *)theLutData.
matrixTRC)[1][1],(*(Matrix2D *)theLutData.
matrixTRC)[1][2],
03096                                                                 (*(Matrix2D *)theLutData.
matrixTRC)[2][0],(*(Matrix2D *)theLutData.
matrixTRC)[2][1],(*(Matrix2D *)theLutData.
matrixTRC)[2][2]);
03097                                         }
03098                                         
if ( createGamutLut )
03099                                         {
03100                                                 
if (DebugLutCheck(kDisplayEXAGamut) )
03101                                                 {
03102                                                         lutString[0] = 
sprintf((
SINT8*)&lutString[1], 
"Gamut-E Lut #%d @ matrixTRC", profLoop);
03103                                                         DoDisplayLutNew(lutString,&theLutData, 0);
03104                                                         lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"Gamut-A Lut #%d @ matrixTRC", profLoop);
03105                                                         DoDisplayLutNew(lutString,&theLutData, 2);
03106                                                 }
03107                                         } 
else if (DebugLutCheck(kDebugEXAReal))
03108                                         {
03109                                                 
03110                                                 lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"E Lut #%d @ matrixTRC", profLoop);
03111                                                 DoDisplayLutNew(lutString,&theLutData, 0);
03112                                                 lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"A Lut #%d @ matrixTRC", profLoop);
03113                                                 DoDisplayLutNew(lutString,&theLutData, 2);
03114                                         }
03115 
#endif
03116 
#ifdef WRITE_LUTS
03117 
                                        if ( !createGamutLut )
03118                                         {
03119                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"E Lut #%d @ matrixTRC", profLoop);
03120                                                 WriteLut2File( fileString,theLutData.
inputLut, 'ELUT');
03121                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"A Lut #%d @ matrixTRC", profLoop);
03122                                                 WriteLut2File( fileString,theLutData.
outputLut, 'ALUT');
03123                                         }
03124 
#endif
03125 
                                        aDoMatrixForCubeStruct.
aElutAdrSize     = theLutData.
inputLutEntryCount;
03126                                         aDoMatrixForCubeStruct.
aElutAdrShift    = 0;
03127                                         aDoMatrixForCubeStruct.
aElutWordSize    = theLutData.
inputLutWordSize;
03128                                         aDoMatrixForCubeStruct.
separateEluts    = 
TRUE;
03129                                         aDoMatrixForCubeStruct.
ein_lut                  = (
UINT16 *)
DATA_2_PTR(theLutData.
inputLut);
03130                                         aDoMatrixForCubeStruct.
aAlutAdrSize     = theLutData.
outputLutEntryCount;
03131                                         aDoMatrixForCubeStruct.
aAlutAdrShift    = 0;
03132                                         aDoMatrixForCubeStruct.
aAlutWordSize    = theLutData.
outputLutWordSize;
03133                                         aDoMatrixForCubeStruct.
separateAluts    = 
TRUE;
03134                                         aDoMatrixForCubeStruct.
aus_lut                  = (
UINT8 *)
DATA_2_PTR(theLutData.
outputLut);
03135                                         aDoMatrixForCubeStruct.
theMatrix                = (
Matrix2D     *)theLutData.
matrixTRC;
03136                                         aDoMatrixForCubeStruct.
aPointCount              = theCubePixelCount;
03137                                         aDoMatrixForCubeStruct.
gridPoints               = gridPointsCube;
03138                                         aDoMatrixForCubeStruct.
aBufferByteCount = theBufferByteCount;
03139                                         aDoMatrixForCubeStruct.
theArr                   = (
UINT8 *)
DATA_2_PTR(inputBuffer);
03140 
#ifdef DEBUG_OUTPUT
03141 
                                        ShowCube16( profLoop, 
"DoMatrixForCube16", createGamutLut, (UINT16 *)
DATA_2_PTR(inputBuffer), gridPointsCube, numOfElutsCube, 3, VAL_USED_BITS );
03142 
#endif
03143 
#ifdef WRITE_LUTS
03144 
                                        if ( !createGamutLut )
03145                                         {
03146                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"DoMat4Cube #%d (TRC)", profLoop);
03147                                                 WriteLut2File( fileString,inputBuffer, 'XLUT');
03148                                         }
03149 
#endif
03150 
                                        DoMatrixForCube16( &aDoMatrixForCubeStruct );
03151 
#ifdef DEBUG_OUTPUT
03152 
                                        ShowCube16( profLoop, 
"after DoMatrixForCube16", createGamutLut, (UINT16 *)
DATA_2_PTR(inputBuffer), gridPointsCube, numOfElutsCube, 3, 8*theBufferByteCount );
03153 
#endif
03154 
#ifdef WRITE_LUTS
03155 
                                        if ( !createGamutLut )
03156                                         {
03157                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"after DoMat4Cube #%d (TRC)", profLoop);
03158                                                 WriteLut2File( fileString,inputBuffer, 'XLUT');
03159                                         }
03160 
#endif
03161 
                                        
03162                                         
UNLOCK_DATA(inputBuffer);
03163                                         
UNLOCK_DATA(theLutData.
inputLut);
03164                                         
UNLOCK_DATA(theLutData.
outputLut);
03165                                         
03166                                 } 
else
03167                                 {
03168                                         
03169 
03170 
03171                                         
03172                                         
03173                                         
if ( theCombiData.
amIPCS && newProfileSet->
prof[profLoop].
renderingIntent == 
icAbsoluteColorimetric )
03174                                         {
03175                                                 
03176                                                 
if (!newProfileSet->
prof[profLoop].
usePreviewTag) {
03177                                                         
LOCK_DATA(inputBuffer);
03178                                                         err = 
DoAbsoluteShiftForPCS_Cube16( (UINT16*)
DATA_2_PTR(inputBuffer), theCubePixelCount,
03179                                                                                                                    theCombiData.
theProfile, (Boolean)(theCombiData.
profileConnectionSpace != icSigLabData), kAbsShiftBeforeDoNDim );
03180                                                         
UNLOCK_DATA(inputBuffer);
03181                                                         
if (err)
03182                                                                 
goto CleanupAndExit;
03183                                                 }
03184                                         }
03185                                         
if (theLutData.
matrixMFT)
03186                                         {
03187                                                 
03188 
03189 
03190                                                 
03191                                                 
LOCK_DATA(inputBuffer);
03192 
#ifdef DEBUG_OUTPUT
03193 
                                                if ( DebugCheck(kThisFile, kDebugMiscInfo) )
03194                                                 {
03195                                                         
DebugPrint(
"Æ matrixMFT: calling DoOnlyMatrixForCube16\n");
03196                                                         
DebugPrint(
"     %f    %f    %f\n     %f    %f    %f\n     %f    %f    %f\n",
03197                                                                 (*(Matrix2D *)theLutData.
matrixMFT)[0][0],(*(Matrix2D *)theLutData.
matrixMFT)[0][1],(*(Matrix2D *)theLutData.
matrixMFT)[0][2],
03198                                                                 (*(Matrix2D *)theLutData.
matrixMFT)[1][0],(*(Matrix2D *)theLutData.
matrixMFT)[1][1],(*(Matrix2D *)theLutData.
matrixMFT)[1][2],
03199                                                                 (*(Matrix2D *)theLutData.
matrixMFT)[2][0],(*(Matrix2D *)theLutData.
matrixMFT)[2][1],(*(Matrix2D *)theLutData.
matrixMFT)[2][2]);
03200                                                 }
03201 
#endif
03202 
#ifdef DEBUG_OUTPUT
03203 
                                                ShowCube16( profLoop, 
"DoOnlyMatrixForCube16 (mft)", createGamutLut, (UINT16 *)
DATA_2_PTR(inputBuffer), gridPointsCube, numOfElutsCube, kNumOfLab_XYZchannels, VAL_USED_BITS );
03204 
#endif
03205 
#ifdef WRITE_LUTS
03206 
                                                if ( !createGamutLut )
03207                                                 {
03208                                                         fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"DoOnlyMat4Cube #%d (mft)", profLoop);
03209                                                         WriteLut2File( fileString,inputBuffer, 'XLUT');
03210                                                 }
03211 
#endif
03212 
                                                DoOnlyMatrixForCube16( (Matrix2D        *)theLutData.
matrixMFT, (Ptr)
DATA_2_PTR(inputBuffer), theCubePixelCount, gridPointsCube );
03213 
#ifdef DEBUG_OUTPUT
03214 
                                                ShowCube16( profLoop, 
"after DoOnlyMatrixForCube16 (mft)", createGamutLut, (UINT16 *)
DATA_2_PTR(inputBuffer), gridPointsCube, numOfElutsCube, kNumOfLab_XYZchannels, VAL_USED_BITS );
03215 
#endif
03216 
#ifdef WRITE_LUTS
03217 
                                                if ( !createGamutLut )
03218                                                 {
03219                                                         fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"DoOnlyMat4Cube #%d (mft)", profLoop);
03220                                                         WriteLut2File( fileString,inputBuffer, 'XLUT');
03221                                                 }
03222 
#endif
03223 
                                                
03224                                                 
UNLOCK_DATA(inputBuffer);
03225                                         }
03226                                         
if (theLutData.
colorLutInDim >= theLutData.
colorLutOutDim && theBufferByteCount == 2 )
03227                                         {
03228                                                 outputBuffer = inputBuffer;
03229                                                 useOutputBuffer = 
FALSE;
03230                                         } 
else
03231                                         {
03232                                                 outputBuffer = 
ALLOC_DATA( (theCubePixelCount + theExtraSize ) * theLutData.
colorLutOutDim * theBufferByteCount, &aOSerr);
03233                                                 err = aOSerr;
03234                                                 
if (err)
03235                                                         
goto CleanupAndExit;
03236                                                 useOutputBuffer = 
TRUE;
03237                                         }
03238                                         
LOCK_DATA(inputBuffer);
03239                                         
LOCK_DATA(outputBuffer);
03240                                         
LOCK_DATA(theLutData.
inputLut);
03241                                         
LOCK_DATA(theLutData.
colorLut);
03242                                         
LOCK_DATA(theLutData.
outputLut);
03243 
#ifdef DEBUG_OUTPUT
03244 
                                        if ( createGamutLut )
03245                                         {
03246                                                 
if ( DebugLutCheck(kDisplayEXAGamut) )
03247                                                 {
03248                                                         lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"Gamut-E Lut #%d @ DoNDim", profLoop);
03249                                                         DoDisplayLutNew(lutString,&theLutData, 0);
03250                                                         lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"Gamut-A Lut #%d @ DoNDim", profLoop);
03251                                                         DoDisplayLutNew(lutString,&theLutData, 2);
03252                                                         lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"Gamut-X Lut #%d @ DoNDim", profLoop);
03253                                                         DoDisplayLutNew(lutString, &theLutData,1);
03254                                                 }
03255                                         } 
else if (DebugLutCheck(kDebugEXAReal) )
03256                                         {
03257                                                         lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"E Lut #%d @ DoNDim", profLoop);
03258                                                         DoDisplayLutNew(lutString,&theLutData, 0);
03259                                                         lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"A Lut #%d @ DoNDim", profLoop);
03260                                                         DoDisplayLutNew(lutString,&theLutData, 2);
03261                                                         lutString[0] = 
sprintf((SINT8*)&lutString[1], 
"X Lut #%d @ DoNDim", profLoop);
03262                                                         DoDisplayLutNew(lutString, &theLutData,1);
03263                                         }
03264 
#endif
03265 
                                        
03266 
#ifdef WRITE_LUTS
03267 
                                        if ( !createGamutLut )
03268                                         {
03269                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"E Lut #%d @ DoNDim", profLoop);
03270                                                 WriteLut2File( fileString,theLutData.
inputLut, 'ELUT');
03271                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"A Lut #%d @ DoNDim", profLoop);
03272                                                 WriteLut2File( fileString,theLutData.
outputLut, 'ALUT');
03273                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"X Lut #%d @ DoNDim", profLoop);
03274                                                 WriteLut2File( fileString,theLutData.
colorLut, 'XLUT');
03275                                         }
03276 
#endif
03277 
03278                                         calcParam.
cmInputColorSpace             = 
cm16PerChannelPacking;
03279                                         calcParam.
cmOutputColorSpace    = theBufferByteCount == 1 ? 
cm8PerChannelPacking : 
cm16PerChannelPacking;
03280                                         calcParam.
cmPixelPerLine                = theCubePixelCount;
03281                                         calcParam.
cmLineCount                   = 1;
03282                                         calcParam.
cmInputPixelOffset    = 
sizeof(
SINT16)*theLutData.
colorLutInDim;
03283                                         calcParam.
cmOutputPixelOffset   = theBufferByteCount*theLutData.
colorLutOutDim;
03284                                         calcParam.
cmInputBytesPerLine   = theCubePixelCount*calcParam.
cmInputPixelOffset;
03285                                         calcParam.
cmOutputBytesPerLine  = theCubePixelCount*calcParam.
cmOutputPixelOffset;
03286 
03287 
03288                                         
for (loop = 0; loop<theLutData.
colorLutInDim; loop++)
03289                                                 calcParam.
inputData[loop]       = (
Ptr)(
DATA_2_PTR(inputBuffer)) + loop * 
sizeof(
SINT16);
03290                                         
for (loop = 0; loop<theLutData.
colorLutOutDim; loop++)
03291                                                 calcParam.
outputData[loop]      = (
Ptr)(
DATA_2_PTR(outputBuffer)) + loop * theBufferByteCount;
03292                                         calcParam.
clearMask                             = 
FALSE;
03293                                         calcParam.
copyAlpha                             = 
FALSE;
03294 
03295 
#ifdef DEBUG_OUTPUT
03296 
                                        ShowCube16( profLoop, 
"DoNDim", createGamutLut, (UINT16 *)
DATA_2_PTR(inputBuffer), gridPointsCube, numOfElutsCube, theLutData.
colorLutInDim, VAL_USED_BITS );
03297 
#endif
03298 
#ifdef WRITE_LUTS
03299 
                                        if ( !createGamutLut )
03300                                         {
03301                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"DoNDim #%d", profLoop);
03302                                                 WriteLut2File( fileString,inputBuffer, 'XLUT');
03303                                         }
03304 
#endif
03305 
03306                                         aDoNDimTableData = theLutData;
03307 
#if ! LUTS_ARE_PTR_BASED
03308 
                                        aDoNDimTableData.
inputLut       = 
DATA_2_PTR(theLutData.inputLut);
03309                                         aDoNDimTableData.
colorLut       = 
DATA_2_PTR(theLutData.colorLut);
03310                                         aDoNDimTableData.
outputLut      = 
DATA_2_PTR(theLutData.outputLut);
03311 
#endif
03312 
                                        if (theLutData.colorLutWordSize == 18)          
03313                                         {
03314                                                 
if ( theBufferByteCount == 1 )
03315                                                         err = 
CalcNDim_Data16To8_Lut8(&calcParam, &aDoNDimTableData);
03316                                                 
else
03317                                                         err = 
CalcNDim_Data16To16_Lut8(&calcParam, &aDoNDimTableData);
03318                                         } 
else
03319                                         {
03320                                                 
if ( theBufferByteCount == 1 )
03321                                                         err = 
CalcNDim_Data16To8_Lut16(&calcParam, &aDoNDimTableData);
03322                                                 
else
03323                                                         err = 
CalcNDim_Data16To16_Lut16(&calcParam, &aDoNDimTableData);
03324                                         }
03325                                         
if (err)
03326                                                 
goto CleanupAndExit;
03327 
#ifdef DEBUG_OUTPUT
03328 
                                        ShowCube16( profLoop, 
"after DoNDim", createGamutLut, (UINT16 *)
DATA_2_PTR(outputBuffer), gridPointsCube, numOfElutsCube, theLutData.colorLutOutDim, 8*theBufferByteCount );
03329 
#endif
03330 
#ifdef WRITE_LUTS
03331 
                                        if ( !createGamutLut )
03332                                         {
03333                                                 fileString[0] = 
sprintf((SINT8*)&fileString[1], 
"after DoNDim #%d", profLoop);
03334                                                 WriteLut2File( fileString,outputBuffer, 'XLUT');
03335                                         }
03336 
#endif
03337 
                                        UNLOCK_DATA(theLutData.inputLut);
03338                                         
UNLOCK_DATA(theLutData.colorLut);
03339                                         
UNLOCK_DATA(theLutData.outputLut);
03340                                         
UNLOCK_DATA(inputBuffer);
03341                                         
UNLOCK_DATA(outputBuffer);
03342                                         
03343                                         
03344                                         
03345                                         
if (newProfileSet->
prof[profLoop].
usePreviewTag && newProfileSet->
prof[profLoop].
renderingIntent == 
icAbsoluteColorimetric) {
03346                                                 
LOCK_DATA(outputBuffer);
03347                                                 err = 
DoAbsoluteShiftForPCS_Cube16( (UINT16*)
DATA_2_PTR(outputBuffer), theCubePixelCount,
03348                                                                                                                    theCombiData.
theProfile, (Boolean)(theCombiData.
profileConnectionSpace != icSigLabData), kAbsShiftAfterDoNDim );
03349                                                 
UNLOCK_DATA(outputBuffer);
03350                                                 
if (err)
03351                                                         
goto CleanupAndExit;
03352                                         }
03353                                         
if ( !theCombiData.
amIPCS && newProfileSet->
prof[profLoop].
renderingIntent == 
icAbsoluteColorimetric )
03354                                         {
03355                                                 
LOCK_DATA(outputBuffer);
03356                                                         err = 
DoAbsoluteShiftForPCS_Cube16( (UINT16*)
DATA_2_PTR(outputBuffer), theCubePixelCount,
03357                                                                                                                    theCombiData.
theProfile, (Boolean)(theCombiData.
profileConnectionSpace != icSigLabData), kAbsShiftAfterDoNDim );
03358                                                 
UNLOCK_DATA(outputBuffer);
03359                                                 
if (err)
03360                                                         
goto CleanupAndExit;
03361                                         }
03362 
03363                                         
if (useOutputBuffer)
03364                                         {
03365                                                 inputBuffer = 
DISPOSE_IF_DATA(inputBuffer);
03366                                                 inputBuffer = outputBuffer;
03367                                         } 
else
03368                                         {
03369                                                 
03370                                                 
03371                         
03372 
03373 
03374 
03375                                         }
03376                                         
03377                         theCubeSize = theCubePixelCount * theLutData.colorLutOutDim * theBufferByteCount;
03378                                         outputBuffer = 
nil;
03379                                 }
03380                         }
03381                 }
03382                 skipCombi = 
FALSE;
03383                 
if( profHeader.
deviceClass == 
icSigLinkClass ){
03384                         theCombiData.
dataColorSpace = profHeader.
pcs;
03385                         theCombiData.
amIPCS = 
TRUE;
03386                 }
03387 
03388                 
if (theCombiData.
amIPCS && !pcsConversion)
03389                         theCombiData.
amIPCS = (theCombiData.
usePreviewTag == 
TRUE) || (theCombiData.
dataColorSpace == 
icSigLabData) || (theCombiData.
dataColorSpace == 
icSigXYZData);
03390                 
else
03391                         theCombiData.
amIPCS = 
TRUE;
03392         }
03393 
#ifdef DEBUG_OUTPUT
03394 
        if ( DebugCheck(kThisFile, kDebugMiscInfo) )
03395                 
DebugPrint(
"  <ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ>\n");
03396 
#endif
03397 
        theLutData.colorLut = 
DISPOSE_IF_DATA(theLutData.colorLut);
03398         theLutData.colorLut = inputBuffer;
03399         inputBuffer = 
nil;
03400 
03401         finalLutData->
colorLut = theLutData.colorLut;   theLutData.colorLut = 
nil;
03402         finalLutData->
colorLutGridPoints = savedGridPoints;
03403         
if ( theBufferByteCount == 1 )
03404                 finalLutData->
colorLutWordSize = 8;
03405         
else
03406                 finalLutData->
colorLutWordSize = 16;
03407         
03408 
03409 
03410 CleanupAndExit:
03411         inputBuffer                      = 
DISPOSE_IF_DATA(inputBuffer);
03412         outputBuffer             = 
DISPOSE_IF_DATA(outputBuffer);
03413         theLutData.inputLut      = 
DISPOSE_IF_DATA(theLutData.inputLut);
03414         theLutData.outputLut = 
DISPOSE_IF_DATA(theLutData.outputLut);
03415         theLutData.colorLut      = 
DISPOSE_IF_DATA(theLutData.colorLut);
03416         theLutData.matrixMFT = 
DisposeIfPtr(theLutData.matrixMFT);
03417         theLutData.matrixTRC = 
DisposeIfPtr(theLutData.matrixTRC);
03418 
03419         
LH_END_PROC(
"CreateCombi")
03420         return err;
03421 }