test: w98/lh_core/genluts.h File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# genluts.h File Reference

Go to the source code of this file.

## Defines

#define | kAbsoluteCalcNothing 0
#define | kAbsoluteCalcBefore 1
#define | kAbsoluteCalcAfter 2
#define | kAbsShiftBeforeDoNDim FALSE
#define | kAbsShiftAfterDoNDim TRUE

## Functions

CMError | FillLuts (CMMModelHandle CMSession, CMProfileRef srcProfile, CMProfileRef dstProfile)
void | CreateLinearElut16 (Ptr theElut, long theSize, long gridPoints, long gridPointsCube)
void | CreateLinearElut (Ptr theElut, long theSize, long gridPoints, long gridPointsCube)
void | CreateLinearAlut (UINT8 *theAlut, long count)
void | CreateLinearAlut16 (UINT16 *theAlut, long aCount)
CMError | DoMakeGamutForMonitor (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData)
CMError | Extract_MFT_Xlut (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData, Ptr profileLutPtr, OSType theTag)
CMError | Extract_MFT_Elut (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData, Ptr profileLutPtr, OSType theTag)
CMError | Extract_MFT_Alut (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData, Ptr profileLutPtr, OSType theTag)
CMError | ExtractAll_MFT_Luts (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData, OSType theTag)
CMError | Extract_TRC_Alut (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData)
CMError | Extract_TRC_Elut (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData)
CMError | Extract_TRC_Matrix (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData)
CMError | ExtractAll_TRC_Luts (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData)
CMError | Extract_Gray_Luts (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData)
CMError | GetMatrixFromProfile (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData, OSType theTag, double factor)
CMError | ExtractAllLuts (CMLutParamPtr theLutData, LHCombiDataPtr theCombiData)
CMError | Create_LH_ProfileSet (CMMModelPtr CMSession, CMConcatProfileSet *profileSet, LHConcatProfileSet **newProfileSet)
CMError | CreateCombi (CMMModelPtr modelingData, CMConcatProfileSet *profileSet, LHConcatProfileSet *newProfileSet, CMLutParamPtr finalLutData, Boolean createGamutLut)
CMError | PrepareCombiLUTs (CMMModelPtr CMSession, CMConcatProfileSet *profileSet)

## Define Documentation

#define kAbsoluteCalcAfter 2

| Definition at line 16 of file w98/lh_core/genluts.h.

#define kAbsoluteCalcBefore 1

| Definition at line 15 of file w98/lh_core/genluts.h.

#define kAbsoluteCalcNothing 0

| Definition at line 14 of file w98/lh_core/genluts.h.

#define kAbsShiftAfterDoNDim TRUE

| Definition at line 19 of file w98/lh_core/genluts.h.

#define kAbsShiftBeforeDoNDim FALSE

| Definition at line 18 of file w98/lh_core/genluts.h.

## Function Documentation

CMError Create_LH_ProfileSet | ( | CMMModelPtr | CMSession,
|  | CMConcatProfileSet * | profileSet,
|  | LHConcatProfileSet ** | newProfileSet
| ) |

Definition at line 1999 of file lh_core/genluts.c.

References Boolean, cmCantConcatenateError, CMError, CMGetProfileElement(), CMGetProfileHeader(), cmProfileError, CMProfileRef, icHeader::colorSpace, LHConcatProfileSet::count, CMConcatProfileSet::count, icHeader::deviceClass, DisposeIfPtr(), dwFlags, FALSE, icAbsoluteColorimetric, icPerceptual, icRelativeColorimetric, icSaturation, icSigAbstractClass, icSigColorSpaceClass, icSigLabData, icSigLinkClass, icSigNamedColorClass, icSigNamedData, icSigPreview0Tag, icSigPreview1Tag, icSigPreview2Tag, icSigXYZData, InitNamedColorProfileData(), kDoLab2XYZ, kDoXYZ2Lab, CMConcatProfileSet::keyIndex, LHConcatProfileSet::keyIndex, kNoInfo, LH_END_PROC, LH_START_PROC, max, NamedColorProfileAtBegin, NamedColorProfileAtEnd, NamedColorProfileOnly, nil, noErr, NoNamedColorProfile, OSErr, OSType, icHeader::pcs, LHProfile::pcsConversionMode, LHConcatProfileSet::prof, LHProfile::profileSet, CMConcatProfileSet::profileSet, Ptr, LHProfile::renderingIntent, icHeader::renderingIntent, SINT16, SmartNewPtrClear(), TRUE, UINT16, UINT32, and LHProfile::usePreviewTag.

Referenced by PrepareCombiLUTs().

    02002 {
    02003         icHeader                                profHeader;
    02004         LHConcatProfileSet*     theProfileSet;
    02005         CMProfileRef                    theProfile;
    02006         OSType                                  previousDataColorSpace  = 0x20202020;
    02007         OSType                                  previousConnectionSpace = 0x20202020;
    02008         UINT32                                  previousRenderingIntent;
    02009         CMError                                 err = noErr;
    02010         OSErr                                   aOSerr = noErr;
    02011         UINT32                                  elementSize = 0;
    02012         SINT16                                  max;
    02013         SINT16                                  theSize;
    02014         SINT16                                  index = 0;
    02015         UINT16                                  profLoop;
    02016         Boolean                                 amIPCS = FALSE;
    02017         OSType                                  theTag;
    02018         UINT32                                  intentIndex = 0;
    02019         long                                    nDeviceCoords;
    02020
    02021         LH_START_PROC("Create_LH_ProfileSet")
    02022
    02023         nDeviceCoords=0;
    02024         max = profileSet->count * 3;
    02025         theSize = sizeof (LHConcatProfileSet) + sizeof(LHProfile) * max;
    02026         theProfileSet = (LHConcatProfileSet *)SmartNewPtrClear(theSize, &aOSerr);
    02027         err = aOSerr;
    02028         if (err)
    02029                 goto CleanupAndExit;
    02030
    02031         theProfileSet->keyIndex = profileSet->keyIndex;
    02032
    02033         CMSession->hasNamedColorProf = NoNamedColorProfile;
    02034         for ( profLoop = 0; profLoop < profileSet->count; profLoop++ )
    02035         {
    02036                 err = CMGetProfileHeader(profileSet->profileSet[profLoop], (CMCoreProfileHeader *)&profHeader);
    02037                 if (err)
    02038                         goto CleanupAndExit;
    02039                 if (profLoop == 0){
    02040 #ifdef RenderInt
    02041                         if( CMSession-> dwFlags != 0xffffffff ){
    02042                                 profHeader.renderingIntent = GetActualRenderingIntent( CMSession, profLoop );
    02043                         }
    02044 #endif
    02045                         theProfileSet->prof[index].renderingIntent = profHeader.renderingIntent;
    02046                 }
    02047                 else{
    02048 #ifdef RenderInt
    02049                         if( CMSession-> dwFlags != 0xffffffff ){
    02050                                 profHeader.renderingIntent = GetActualRenderingIntent( CMSession, profLoop );
    02051                                 previousRenderingIntent = profHeader.renderingIntent;
    02052                         }
    02053 #endif
    02054                         theProfileSet->prof[index].renderingIntent = previousRenderingIntent;
    02055                 }
    02056                 if ( (profLoop > 0) && (profLoop < profileSet->count - 1) )
    02057                 {
    02058                         /*----------------------------------------------------------------------------- color space conv. inbetween? -> ignore the profile*/
    02059                         if( profHeader.deviceClass == icSigColorSpaceClass )
    02060                                 continue;
    02061                         if( profHeader.deviceClass == icSigNamedColorClass ){
    02062                                 err = cmCantConcatenateError;
    02063                                 goto CleanupAndExit;
    02064                         }
    02065                 }
    02066                 /*-------------------------------------------------------------------------------------------------------
    02067                    if we have non matching pcs color spaces, we have to add a conversion between Lab and XYZ
    02068                   -------------------------------------------------------------------------------------------------------*/
    02069                 if( profHeader.deviceClass == icSigNamedColorClass ){
    02070                         err = InitNamedColorProfileData( CMSession, profileSet->profileSet[profLoop], profHeader.pcs, &nDeviceCoords );
    02071                         if (err)
    02072                                 goto CleanupAndExit;
    02073                         profHeader.pcs = icSigLabData;
    02074                         if( profileSet->count == 1 ){
    02075                                 CMSession->hasNamedColorProf = NamedColorProfileOnly;
    02076                                 //CMSession->dataColorSpace = profHeader.colorSpace;
    02077                         }
    02078                         else if( profLoop == 0 ){
    02079                                 CMSession->hasNamedColorProf = NamedColorProfileAtBegin;
    02080                                 profHeader.colorSpace = icSigNamedData;
    02081                                 CMSession->firstColorSpace = icSigNamedData;
    02082                                 theProfileSet->prof[index].pcsConversionMode = kNoInfo;
    02083                                 theProfileSet->prof[index].profileSet = 0;
    02084                                 index++;
    02085                                 theProfileSet->prof[index].renderingIntent = previousRenderingIntent;
    02086                                 previousDataColorSpace = (OSType)profHeader.colorSpace;
    02087                         }
    02088                         else if( profLoop == profileSet->count-1 ){
    02089                                 CMSession->hasNamedColorProf = NamedColorProfileAtEnd;
    02090                                 CMSession->lastColorSpace = icSigNamedData;
    02091                                 profHeader.colorSpace = icSigNamedData;
    02092                                 theProfileSet->prof[index].pcsConversionMode = kNoInfo;
    02093                                 theProfileSet->prof[index].profileSet = 0;
    02094                                 index++;
    02095                                 theProfileSet->prof[index].renderingIntent = previousRenderingIntent;
    02096                         }
    02097                 }
    02098                 if (amIPCS)
    02099                 {
    02100                         if (previousConnectionSpace != (OSType)profHeader.pcs)
    02101                         {
    02102                                 /* insert a XYZ <--> Lab conversion lut */
    02103                                 if (previousConnectionSpace == icSigLabData)
    02104                                         theProfileSet->prof[index].pcsConversionMode = kDoLab2XYZ;              /* create Lab->XYZ */
    02105                                 else
    02106                                         theProfileSet->prof[index].pcsConversionMode = kDoXYZ2Lab;              /* create XYZ->Lab */
    02107                                 index++;
    02108                                 theProfileSet->prof[index].renderingIntent = previousRenderingIntent;
    02109                         }
    02110                 } else if (index > 0)
    02111                 {
    02112                         if ( previousDataColorSpace != (OSType)profHeader.colorSpace)
    02113                         {
    02114                                 /* copy old profile for back transform to pcs */
    02115                                 theProfileSet->prof[index].profileSet = theProfileSet->prof[index-1].profileSet;
    02116                                 index++;
    02117                                 theProfileSet->count = index;
    02118
    02119                                 if (previousConnectionSpace != (OSType)profHeader.pcs)
    02120                                 {
    02121                                         /* insert a XYZ <--> Lab conversion lut */
    02122                                         if (previousConnectionSpace == icSigLabData)
    02123                                                 theProfileSet->prof[index].pcsConversionMode = kDoLab2XYZ;              /* create Lab->XYZ */
    02124                                         else
    02125                                                 theProfileSet->prof[index].pcsConversionMode = kDoXYZ2Lab;              /* create XYZ->Lab */
    02126                                         theProfileSet->prof[index].renderingIntent = previousRenderingIntent;
    02127                                         index++;
    02128                                 }
    02129
    02130                                 previousDataColorSpace  = profHeader.colorSpace;
    02131                                 previousConnectionSpace = profHeader.pcs;
    02132                                 amIPCS = TRUE;
    02133                         }
    02134                 }
    02135
    02136                 /*-------------------------------------------------------------------------------------------------------
    02137                    copy the profile from the original profileSet to the LinoProfileSet
    02138                   -------------------------------------------------------------------------------------------------------*/
    02139                 theProfileSet->prof[index].profileSet = profileSet->profileSet[profLoop];
    02140                 if( profHeader.deviceClass == icSigNamedColorClass ){
    02141                         theProfileSet->prof[index].profileSet = 0;
    02142                 }
    02143                 index++;
    02144                 if( intentIndex < CMSession-> nIntents -1 ) intentIndex++;
    02145                 /*-------------------------------------------------------------------------------------------------------
    02146                    more than 2 profiles -> we have to double the profile in our own LHConcatProfileSet
    02147                    if we have the profiles  RGB  RGB  RGB  we will now correctly generate: RGB  RGB  rgb  RGB
    02148                                             XYZ  XYZ  XYZ                                  XYZ  XYZ  xyz  XYZ
    02149                   -------------------------------------------------------------------------------------------------------*/
    02150                 if( amIPCS && (profLoop > 0) && (profLoop < profileSet->count - 1) )
    02151                 {
    02152                         /*----------------------------------------------------------------------------- color space conv. inbetween? -> ignore the profile*/
    02153                         if (profHeader.deviceClass == icSigColorSpaceClass)
    02154                                 index--;                                                                                /* not used. behavior changed. see above */
    02155                         else
    02156                         {
    02157                                 /*------------------------------------------------------------------------- if the inserted profile contains a preview tag, then use it...*/
    02158                                 theProfile = theProfileSet->prof[index-1].profileSet;
    02159
    02160                                 /* Do we check the right preview tag for the intent */
    02161                                 switch (previousRenderingIntent)
    02162                                 {
    02163                                         case icPerceptual:                              /* Photographic images */
    02164                                                 theTag = icSigPreview0Tag;
    02165                                                 break;
    02166
    02167                                         case icRelativeColorimetric:    /* Logo Colors */
    02168                                                 theTag = icSigPreview1Tag;
    02169                                                 break;
    02170
    02171                                         case icSaturation:                              /* Business graphics */
    02172                                                 theTag = icSigPreview2Tag;
    02173                                                 break;
    02174
    02175                                         case icAbsoluteColorimetric:    /* Logo Colors */
    02176                                                 theTag = icSigPreview1Tag;
    02177                                                 break;
    02178
    02179                                         default:
    02180                                                 err = cmProfileError;
    02181                                                 goto CleanupAndExit;
    02182                                 }
    02183                                 err = CMGetProfileElement(theProfile, theTag, &elementSize, nil);
    02184
    02185                                 if (err == noErr)
    02186                                 {
    02187                                         theProfileSet->prof[index-1].usePreviewTag = TRUE;
    02188                                         theProfileSet->prof[index-1].renderingIntent = profHeader.renderingIntent;      /* for concate absolute */
    02189                                 } else
    02190                                 {
    02191                                 /*------------------------------------------------------------------------- ... else insert the same profile once more */
    02192                                         if ( (profHeader.deviceClass != icSigAbstractClass) && (profHeader.deviceClass != icSigLinkClass) && (profHeader.deviceClass != icSigNamedColorClass) )
    02193                                         {
    02194 #ifdef RenderInt
    02195                                                 if( CMSession-> dwFlags != 0xffffffff ){
    02196                                                         profHeader.renderingIntent = GetActualRenderingIntent( CMSession, 0xffffffff );
    02197                                                 }
    02198 #endif
    02199                                                 theProfileSet->prof[index].profileSet = profileSet->profileSet[profLoop];
    02200                                                 theProfileSet->prof[index].renderingIntent = profHeader.renderingIntent;/* for concate absolute */
    02201                                                 index++;
    02202                                         }
    02203                                 }
    02204                                 amIPCS = FALSE;         /* will force that we stay in PCS... */
    02205                         }
    02206                 }
    02207                 theProfileSet->count = index;
    02208                 previousDataColorSpace  = profHeader.colorSpace;
    02209                 previousConnectionSpace = profHeader.pcs;
    02210                 previousRenderingIntent = profHeader.renderingIntent;
    02211
    02212                 if( profHeader.deviceClass == icSigLinkClass ){
    02213                         previousDataColorSpace = profHeader.pcs;
    02214                         amIPCS = TRUE;
    02215                 }
    02216                 if (amIPCS)
    02217                         amIPCS = (previousDataColorSpace == icSigLabData) || (previousDataColorSpace == icSigXYZData);
    02218                 else
    02219                         amIPCS = TRUE;
    02220         }
    02221
    02222 #ifdef ALLOW_DEVICE_LINK
    02223         if( (CMSession)->appendDeviceLink ){
    02224                 if( previousDataColorSpace == (CMSession)->lastColorSpace ){
    02225                         theProfileSet->prof[index].profileSet = profileSet->profileSet[profLoop];
    02226                         theProfileSet->prof[index].renderingIntent = icPerceptual;
    02227                         index++;
    02228                         theProfileSet->count = index;
    02229                         err = CMGetProfileHeader(profileSet->profileSet[profLoop], (CMCoreProfileHeader *)&profHeader);
    02230                         if (err)
    02231                                 goto CleanupAndExit;
    02232                         (CMSession)->lastColorSpace = profHeader.pcs;
    02233                 }
    02234                 else{
    02235                         err = cmCantConcatenateError;
    02236                         goto CleanupAndExit;
    02237                 }
    02238         }
    02239         if( CMSession->hasNamedColorProf == NamedColorProfileAtEnd || CMSession->hasNamedColorProf == NamedColorProfileOnly ){
    02240                         theProfileSet->count--;
    02241         }
    02242         if( CMSession->hasNamedColorProf == NamedColorProfileAtBegin ){
    02243                 theProfileSet->count--;                                 /* remove first profile */
    02244                 for( profLoop=0; profLoop<theProfileSet->count; profLoop++){
    02245                         theProfileSet->prof[profLoop] = theProfileSet->prof[profLoop+1];
    02246                 }
    02247         }
    02248 #endif
    02249         *newProfileSet = theProfileSet;
    02250         theProfileSet = nil;
    02251         /* ---------------------------------------------------------------------------------
    02252             clean up
    02253            --------------------------------------------------------------------------------- */
    02254 CleanupAndExit:
    02255         theProfileSet = (LHConcatProfileSet *)DisposeIfPtr((Ptr)theProfileSet);
    02256
    02257         LH_END_PROC("Create_LH_ProfileSet")
    02258         return err;
    02259 }

CMError CreateCombi | ( | CMMModelPtr | modelingData,
|  | CMConcatProfileSet * | profileSet,
|  | LHConcatProfileSet * | newProfileSet,
|  | CMLutParamPtr | finalLutData,
|  | Boolean | createGamutLut
| ) |

Definition at line 2423 of file lh_core/genluts.c.

References DoMatrixForCubeStruct::aAlutAdrShift, DoMatrixForCubeStruct::aAlutAdrSize, DoMatrixForCubeStruct::aAlutWordSize, DoMatrixForCubeStruct::aBufferByteCount, adr_breite_alut, adr_breite_elut, DoMatrixForCubeStruct::aElutAdrShift, DoMatrixForCubeStruct::aElutAdrSize, DoMatrixForCubeStruct::aElutWordSize, ALLOC_DATA, LHCombiData::amIPCS, DoMatrixForCubeStruct::aPointCount, DoMatrixForCubeStruct::aus_lut, bit_breite_alut, bit_breite_elut, BlockMoveData, Boolean, CalcGridPoints4Cube(), CalcNDim_Data16To16_Lut16(), CalcNDim_Data16To16_Lut8(), CalcNDim_Data16To8_Lut16(), CalcNDim_Data16To8_Lut8(), CMCalcParam::clearMask, cm16PerChannelPacking, cm8PerChannelPacking, cmBestMode, cmDraftMode, CMError, CMGetProfileHeader(), CMCalcParam::cmInputBytesPerLine, CMCalcParam::cmInputColorSpace, CMCalcParam::cmInputPixelOffset, CMCalcParam::cmLineCount, cmNormalMode, CMCalcParam::cmOutputBytesPerLine, CMCalcParam::cmOutputColorSpace, CMCalcParam::cmOutputPixelOffset, CMCalcParam::cmPixelPerLine, cmProfileError, CMLutParam::colorLut, CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, CMLutParam::colorLutWordSize, icHeader::colorSpace, CMCalcParam::copyAlpha, CMConcatProfileSet::count, LHConcatProfileSet::count, CreateLinearAlut(), CreateLinearAlut16(), CreateLinearElut(), CreateLinearElut16(), CUBE_DATA_TYPE, DATA_2_PTR, LHCombiData::dataColorSpace, DebugPrint, icHeader::deviceClass, DISPOSE_IF_DATA, DisposeIfPtr(), DoAbsoluteShiftForPCS_Cube16(), LHCombiData::doCreate_16bit_ALut, LHCombiData::doCreate_16bit_Combi, LHCombiData::doCreate_16bit_ELut, LHCombiData::doCreate_16bit_XLut, LHCombiData::doCreateGamutLut, LHCombiData::doCreateLinkProfile, DoMatrixForCube16(), DoOnlyMatrixForCube16(), dwFlags, DoMatrixForCubeStruct::ein_lut, ExtractAllLuts(), FALSE, icHeader::flags, DoMatrixForCubeStruct::gridPoints, LHCombiData::gridPointsCube, icAbsoluteColorimetric, icSigCmyData, icSigCmykData, icSigGrayData, icSigHlsData, icSigHsvData, icSigLabData, icSigLinkClass, icSigLuvData, icSigMCH2Data, icSigMCH3Data, icSigMCH4Data, icSigMCH5Data, icSigMCH6Data, icSigMCH7Data, icSigMCH8Data, icSigNamedData, icSigRgbData, icSigXYZData, icSigYCbCrData, icSigYxyData, CMCalcParam::inputData, CMLutParam::inputLut, CMLutParam::inputLutEntryCount, CMLutParam::inputLutWordSize, kAbsShiftAfterDoNDim, kAbsShiftBeforeDoNDim, kCMMNewLinkProfile, kDoLab2XYZ, kDoXYZ2Lab, kNumOfLab_XYZchannels, kQualityMask, Lab2XYZ_forCube16(), LH_END_PROC, LH_START_PROC, LOCK_DATA, MakeCube16(), MakeSpecialCube16(), Matrix2D, CMLutParam::matrixMFT, CMLutParam::matrixTRC, LHCombiData::maxProfileCount, NamedColorProfileAtBegin, NamedColorProfileAtEnd, nil, noErr, OSErr, CMCalcParam::outputData, CMLutParam::outputLut, CMLutParam::outputLutEntryCount, CMLutParam::outputLutWordSize, icHeader::pcs, LHProfile::pcsConversionMode, LHCombiData::precision, LHConcatProfileSet::prof, LHCombiData::profileClass, LHCombiData::profileConnectionSpace, LHProfile::profileSet, CMConcatProfileSet::profileSet, LHCombiData::profLoop, Ptr, LHProfile::renderingIntent, LHCombiData::renderingIntent, DoMatrixForCubeStruct::separateAluts, DoMatrixForCubeStruct::separateEluts, SetMem(), SINT16, SINT32, SINT8, sprintf(), Str255, DoMatrixForCubeStruct::theArr, DoMatrixForCubeStruct::theMatrix, LHCombiData::theProfile, TRUE, UINT16, UINT32, UINT8, UNLOCK_DATA, LHProfile::usePreviewTag, LHCombiData::usePreviewTag, VAL_USED_BITS, and XYZ2Lab_forCube16().

Referenced by PrepareCombiLUTs().

    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         /*long                          SavegridPointsCube;*/
    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;                    /* amIPCS has to be FALSE at the beginning of the chain */
    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 )            /* first fix - best mode creates 16-bit luts */
    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;               /* 5462 * 3 Å 4 * 8 * 8 * 8 * 8         ->  allow 8^4 */
    02532                         break;
    02533                 case cmBestMode:
    02534                         if (createGamutLut)
    02535                                 theCubePixelCount = 87382;
    02536                         else
    02537                                 theCubePixelCount = 87382;   /* 87382 * 3 Å 4 * 16 * 16 * 16 * 16;      ->  allow 16^4  !!! */
    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 );          /* 3 input channels */
    02560                         break;
    02561                 case icSigGrayData:
    02562                         theCubeSize = 255 ;
    02563                         err = CalcGridPoints4Cube ( theCubeSize, 1, &theCombiData.gridPointsCube, &gridBits );          /* 1 input channel  */
    02564                         break;
    02565                 case icSigCmykData:
    02566                 case icSigMCH4Data:
    02567                         err = CalcGridPoints4Cube ( theCubeSize, 4, &theCombiData.gridPointsCube, &gridBits );          /* 4 input channels */
    02568                         break;
    02569                 case icSigMCH2Data:
    02570                         err = CalcGridPoints4Cube ( theCubeSize, 2, &theCombiData.gridPointsCube, &gridBits );          /* 2 input channels */
    02571                         break;
    02572                 case icSigMCH5Data:
    02573                         err = CalcGridPoints4Cube ( theCubeSize, 5, &theCombiData.gridPointsCube, &gridBits );          /* 5 input channels */
    02574                         break;
    02575                 case icSigMCH6Data:
    02576                         err = CalcGridPoints4Cube ( theCubeSize, 6, &theCombiData.gridPointsCube, &gridBits );          /* 6 input channels */
    02577                         break;
    02578                 case icSigMCH7Data:
    02579                         err = CalcGridPoints4Cube ( theCubeSize, 7, &theCombiData.gridPointsCube, &gridBits );          /* 7 input channels */
    02580                         break;
    02581                 case icSigMCH8Data:
    02582                         err = CalcGridPoints4Cube ( theCubeSize, 8, &theCombiData.gridPointsCube, &gridBits );          /* 8 input channels */
    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         /*bIsLabConnection = 0;*/
    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           --                                  loop over all profiles
    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; /* UWE 9.2.96 */
    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;       /* UWE 9.2.96 */
    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                         /*------------------------ free pointers... */
    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                                         pcsConversion: we have to convert:     XYZ <-->  Lab
    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                                 /*if ( modelingData->hasNamedColorProf == NamedColorProfileAtBegin ){
    02702                                         inputBuffer = theLutData.colorLut;
    02703                                         theLutData.colorLut = 0;
    02704                                         QuantizeNamedValues( modelingData, inputBuffer, theCubeSize/theLutData.colorLutInDim );
    02705                                         theCombiData.amIPCS = TRUE;
    02706 #ifdef DEBUG_OUTPUT
    02707                                         ShowCube16( profLoop, "after Lab<->XYZ", createGamutLut, (UINT16 *)DATA_2_PTR(theLutData.colorLut), gridPointsCube, theLutData.colorLutInDim, 3, VAL_USED_BITS );
    02708 #endif
    02709                                         UNLOCK_DATA(theLutData.colorLut);
    02710                                         skipCombi = FALSE;
    02711                                         theLutData.colorLutInDim = kNumOfLab_XYZchannels;
    02712                                         theLutData.colorLutOutDim = kNumOfLab_XYZchannels;
    02713                                         continue;
    02714                                 }
    02715                                 else */
    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                                         NO pcsConversion: we are dealing with a profile
    02743                                   ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
    02744                                 theCombiData.doCreateGamutLut = createGamutLut && (profLoop == newProfileSet->count - 1);
    02745                                 theCombiData.usePreviewTag        = (UINT8)newProfileSet->prof[profLoop].usePreviewTag;
    02746
    02747                                 /*----------------------------------------------------------------------------------------------
    02748                                    get data out of the profile
    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                            save first Elut...
    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                                         /*------------------------create and initialize cube*/
    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                                 /*theSize = GETDATASIZE(theLutData.inputLut);   */                      /* save final ELUT */
    02834                                 theSize = theLutData.inputLutEntryCount * theLutData.colorLutInDim;                             /* save final ELUT */
    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                                         /*------------------------------------------------------------------------------------------ create linear elut*/
    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                                         /*------------------------------------------------------------------------------------------ create linear elut*/
    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                            save last Alut...
    02908                           ----------------------------------------------------------------------------------------------*/
    02909                         if (profLoop == newProfileSet->count - 1)
    02910                         {
    02911                                 /*theSize = GETDATASIZE(theLutData.outputLut);*/
    02912                                 theSize = theLutData.outputLutEntryCount * theLutData.colorLutOutDim;                           /* save final ALUT */
    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)/* UWE 9.2.96*/
    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;                 /* last should be Byte ALUT*/
    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                                         we have either only one profile -or- we did do a pcsConversion
    02975                                   =============================================================================================*/
    02976                                 if (newProfileSet->count == 1){                 /* one profile */
    02977                                         theSize = 1;
    02978                                         theExtraSize = 1;
    02979                                         for( loop=0; loop<(theLutData.colorLutInDim-1); ++loop){        /* Extra Size for Interpolation */
    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++; /* +1 for MMX 4 Byte access */
    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 /*                                      if( theCombiData.doCreate_16bit_Combi ){
    03037                                                 if( theLutData.colorLutWordSize == 8 ){
    03038                                                         theSize = 1;
    03039                                                         for( loop=0; loop<theLutData.colorLutInDim; ++loop){
    03040                                                                 theSize *= theLutData.colorLutGridPoints;
    03041                                                         }
    03042                                 theSize = theSize *  theLutData.colorLutOutDim;
    03043                                                         inputBuffer = DISPOSE_IF_DATA(inputBuffer);
    03044                                                         inputBuffer = ALLOC_DATA( theSize * 2+2, &aOSerr );
    03045                                                         err = aOSerr;
    03046                                                         if (err)
    03047                                                                 goto CleanupAndExit;
    03048
    03049                                                         LOCK_DATA(theLutData.colorLut);
    03050                                                         LOCK_DATA(inputBuffer);
    03051                                                         wordPtr = DATA_2_PTR( inputBuffer );
    03052                                                         xlutPtr = DATA_2_PTR( theLutData.colorLut );
    03053                                                         for( loop=0; loop<theSize; ++loop){
    03054                                                                 aUINT16 = (UINT16)xlutPtr[loop];
    03055                                                                 wordPtr[loop] = (aUINT16<<8) | aUINT16;
    03056                                                         }
    03057                                                         UNLOCK_DATA(theLutData.colorLut);
    03058                                                         UNLOCK_DATA(inputBuffer);
    03059                                                         theLutData.colorLut = inputBuffer;
    03060                                                         theLutData.colorLutWordSize = 16;
    03061                                                         inputBuffer = 0;
    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) )/* UWE 9.2.96*/
    03073                                         theBufferByteCount = 1;                 /* last should be Byte ALUT*/
    03074
    03075                         } else
    03076                         {
    03077                                 /*=============================================================================================
    03078                                         create combi
    03079                                   =============================================================================================*/
    03080                                 if (theLutData.matrixTRC)
    03081                                 {
    03082                                         /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    03083                                            the profile contained a matrix/TRC:
    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                                         /*SETDATASIZE(inputBuffer, theCubePixelCount * theLutData.colorLutOutDim * theBufferByteCount);*/
    03166                                 } else
    03167                                 {
    03168                                         /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    03169                                            the profile contained a mft
    03170                                           +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
    03171
    03172                                         /*----------------------------------------------------------------------------------------- absolute colorimetry*/
    03173                                         if ( theCombiData.amIPCS && newProfileSet->prof[profLoop].renderingIntent == icAbsoluteColorimetric )
    03174                                         {
    03175                                                 /*for concate absolute, make sure this is not done when preview tag exists)*/
    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                                                    the profile contained a mft AND a matrix:
    03189                                                   -----------------------------------------------------------------------------------------*/
    03190                                                 /*------------------------------------ pcs is Lab -> handle direct (without Elut and Alut) */
    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 /*                                      calcParam.cmInputBytesPerPixel  = calcParam.cmInputPixelOffset; */
    03287 /*                                      calcParam.cmOutputBytesPerPixel = calcParam.cmOutputPixelOffset;*/
    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                                         /*----------------------------------------------------------------------------------------- absolute colorimetry*/
    03344                                         /*for concate absolute, make sure this IS done when preview tag exists)*/
    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                                                 /*SETDATASIZE(inputBuffer, theCubePixelCount * theLutData.colorLutOutDim * theBufferByteCount);*/
    03370                                                 /*err = MemError();*/
    03371                         /*inputBuffer = ALLOC_DATA( theCubePixelCount * theLutData.colorLutOutDim * theBufferByteCount, &aOSerr );
    03372                                                 err = aOSerr;
    03373                                                 if (err)
    03374                                                         goto CleanupAndExit;*/
    03375                                         }
    03376                                         /*theCubeSize = GETDATASIZE(inputBuffer)/theBufferByteCount;*/
    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             clean up
    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 }

void CreateLinearAlut | ( | UINT8 * | theAlut,
|  | long | count
| ) |

| Referenced by CreateCombi(), Extract_Gray_Luts(), and Extract_TRC_Alut().

void CreateLinearAlut16 | ( | UINT16 * | theAlut,
|  | long | aCount
| ) |

| Referenced by CreateCombi(), Extract_Gray_Luts(), and Extract_TRC_Alut().

void CreateLinearElut | ( | Ptr | theElut,
|  | long | theSize,
|  | long | gridPoints,
|  | long | gridPointsCube
| ) |

| Referenced by CreateCombi(), Extract_Gray_Luts(), and Extract_TRC_Elut().

void CreateLinearElut16 | ( | Ptr | theElut,
|  | long | theSize,
|  | long | gridPoints,
|  | long | gridPointsCube
| ) |

| Referenced by CreateCombi(), Extract_Gray_Luts(), and Extract_TRC_Elut().

CMError DoMakeGamutForMonitor | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData
| ) |

Definition at line 380 of file lh_core/genluts.c.

References adr_bereich_alut, adr_breite_elut, bit_breite_alut, cmBestMode, CMError, CMGetProfileElement(), CMLutParam::colorLut, CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, CMLutParam::colorLutWordSize, icXYZType::data, DATA_2_PTR, FALSE, icSigBlueColorantTag, icSigGreenColorantTag, icSigRedColorantTag, CMLutParam::inputLutEntryCount, CMLutParam::inputLutWordSize, LH_END_PROC, LH_START_PROC, LHCombiDataPtr, LOCK_DATA, MakeGamut16or32ForMonitor(), nil, noErr, OSType, CMLutParam::outputLutEntryCount, CMLutParam::outputLutWordSize, LHCombiData::precision, SINT16, LHCombiData::theProfile, TRUE, UINT32, UNLOCK_DATA, and VAL_USED_BITS.

Referenced by ExtractAllLuts().

    00382 {
    00383         OSType                  colorantTags[3];
    00384         icXYZType               colorantData[3];
    00385         SINT16                  loop;
    00386         CMError                 err;
    00387         UINT32  elementSize;
    00388
    00389         LH_START_PROC("DoMakeGamutForMonitor")
    00390
    00391         colorantTags[0] = icSigRedColorantTag;
    00392         colorantTags[1] = icSigGreenColorantTag;
    00393         colorantTags[2] = icSigBlueColorantTag;
    00394
    00395         /* --------------------------------------------------------------------------------- */
    00396         for (loop = 0; loop < 3; loop++)
    00397         {
    00398                 err = CMGetProfileElement(theCombiData->theProfile, colorantTags[loop], &elementSize, nil);
    00399                 if (err != noErr)
    00400                         goto CleanupAndExit;
    00401                 err = CMGetProfileElement(theCombiData->theProfile, colorantTags[loop], &elementSize, &colorantData[loop]);
    00402 #ifdef IntelMode
    00403         SwapLongOffset( &colorantData[loop].base.sig, 0, 4 );
    00404         SwapLongOffset( &colorantData[loop], (ULONG)((char*)&colorantData[0].data.data[0]-(char*)&colorantData[0]), elementSize );
    00405 #endif
    00406                 if (err != noErr)
    00407                         goto CleanupAndExit;
    00408         }
    00409
    00410         if ( theCombiData->precision == cmBestMode )
    00411         {
    00412                 err = MakeGamut16or32ForMonitor( &colorantData[0], &colorantData[1], &colorantData[2], theLutData, TRUE );
    00413                 theLutData->colorLutGridPoints  = 32;
    00414         }
    00415         else
    00416         {
    00417                 err = MakeGamut16or32ForMonitor( &colorantData[0], &colorantData[1], &colorantData[2], theLutData, FALSE);
    00418                 theLutData->colorLutGridPoints  = 16;
    00419         }
    00420         theLutData->colorLutInDim       = 3;
    00421         theLutData->colorLutOutDim      = 1;
    00422         theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    00423         theLutData->inputLutWordSize = VAL_USED_BITS;
    00424         theLutData->outputLutEntryCount = adr_bereich_alut;
    00425         theLutData->outputLutWordSize = bit_breite_alut;
    00426         theLutData->colorLutWordSize = 8;
    00427
    00428 #ifdef DEBUG_OUTPUT
    00429         if ( DebugLutCheck( kDisplayGamut ) )
    00430         {
    00431                 LOCK_DATA(theLutData->colorLut);
    00432                 if (theCombiData->precision == cmBestMode)
    00433                         Show32by32by32GamutXLUT(DATA_2_PTR(theLutData->colorLut));
    00434                 else
    00435                         Show16by16by16GamutXLUT(DATA_2_PTR(theLutData->colorLut));
    00436                 UNLOCK_DATA(theLutData->colorLut);
    00437         }
    00438 #endif
    00439
    00440 CleanupAndExit:
    00441
    00442         LH_END_PROC("DoMakeGamutForMonitor")
    00443         return err;
    00444 }

CMError Extract_Gray_Luts | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData
| ) |

Definition at line 1461 of file lh_core/genluts.c.

References adr_breite_alut, adr_breite_elut, ALLOC_DATA, LHCombiData::amIPCS, icCurveType::base, bit_breite_alut, bit_breite_elut, BlockMoveData, CMError, CMGetProfileElement(), CMLutParam::colorLut, CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, CMLutParam::colorLutWordSize, icCurve::count, CreateLinearAlut(), CreateLinearAlut16(), CreateLinearElut(), CreateLinearElut16(), icCurveType::curve, icCurve::data, DATA_2_PTR, DISPOSE_IF_DATA, DisposeIfPtr(), LHCombiData::doCreate_16bit_ALut, LHCombiData::doCreate_16bit_Combi, LHCombiData::doCreate_16bit_ELut, Fill_inverse_byte_ALUT_from_CurveTag(), Fill_inverse_ushort_ALUT_from_CurveTag(), Fill_ushort_ELUT_from_CurveTag(), LHCombiData::gridPointsCube, icSigGrayTRCTag, icSigLabData, CMLutParam::inputLut, CMLutParam::inputLutEntryCount, CMLutParam::inputLutWordSize, LH_END_PROC, LH_START_PROC, LOCK_DATA, LUT_DATA_TYPE, nil, noErr, OSErr, CMLutParam::outputLut, CMLutParam::outputLutEntryCount, CMLutParam::outputLutWordSize, LHCombiData::profileConnectionSpace, Ptr, SetMem(), SetMem16(), icTagBase::sig, SINT16, SINT32, SINT8, SmartNewPtr(), LHCombiData::theProfile, UINT16, UINT32, UINT8, UNLOCK_DATA, and VAL_USED_BITS.

Referenced by ExtractAllLuts().

    01463 {
    01464         CMError                 err = noErr;
    01465         OSErr                   aOSerr = noErr;
    01466         LUT_DATA_TYPE   theElut = nil;
    01467         LUT_DATA_TYPE   theXlut = nil;
    01468         LUT_DATA_TYPE   theAlut = nil;
    01469         SINT32                  theElutSize;
    01470         SINT32                  theAlutSize;
    01471         SINT32                  theXlutSize;
    01472         SINT32                  loop;
    01473         UINT32                  elementSize;
    01474         UINT8*                  bytePtr            = nil;
    01475         UINT16*                 wordPtr            = nil;
    01476         icCurveType*    pCurveTag          = nil;
    01477         SINT32                  theSize;
    01478
    01479         LH_START_PROC("Extract_Gray_Luts")
    01480
    01481         theLutData->colorLutGridPoints = 2;
    01482
    01483         if (theCombiData->amIPCS)
    01484         {
    01485                 theLutData->colorLutInDim = 3;
    01486                 theLutData->colorLutOutDim = 1;
    01487         } else
    01488         {
    01489                 theLutData->colorLutInDim = 1;
    01490                 theLutData->colorLutOutDim = 3;
    01491         }
    01492
    01493         if (err)
    01494                 goto CleanupAndExit;
    01495
    01496         /* --------------------------------------------------------------------------------- get tag data */
    01497         err = CMGetProfileElement(theCombiData->theProfile, icSigGrayTRCTag, &elementSize, nil);
    01498         if (err)
    01499                 goto CleanupAndExit;
    01500         pCurveTag = (icCurveType *)SmartNewPtr(elementSize, &aOSerr);
    01501         err = aOSerr;
    01502         if (err)
    01503                 goto CleanupAndExit;
    01504         err = CMGetProfileElement(theCombiData->theProfile, icSigGrayTRCTag, &elementSize, pCurveTag);
    01505 #ifdef IntelMode
    01506     SwapLongOffset( &pCurveTag->base.sig, 0, 4 );
    01507     SwapLong( &pCurveTag->curve.count );
    01508     SwapShortOffset( pCurveTag, (ULONG)((SINT8*)&pCurveTag->curve.data[0]-(SINT8*)pCurveTag), elementSize );
    01509 #endif
    01510         if (err)
    01511                 goto CleanupAndExit;
    01512
    01513         /* ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
    01514                                                                                                         X l u t
    01515            ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/
    01516         if ( theCombiData->profileConnectionSpace == icSigLabData )
    01517         {
    01518                 if (theCombiData->amIPCS)                       /*------------------------------------------------ Lab -> Gray */
    01519                 {
    01520                         theXlutSize = ((1 << theLutData->colorLutInDim)+1 ) * (theLutData->colorLutOutDim) * sizeof(UINT16); /*+1=Extra Size for Interpolatio UK13.8.96*/
    01521                         theXlut = ALLOC_DATA(theXlutSize + sizeof (UINT16), &aOSerr);
    01522                         err = aOSerr;
    01523                         if (err)
    01524                                 goto CleanupAndExit;
    01525                         LOCK_DATA(theXlut);
    01526                         wordPtr = (UINT16*)DATA_2_PTR(theXlut);
    01527                         *(wordPtr    )  = 0x0000;
    01528                         *(wordPtr + 1)  = 0x0000;
    01529                         *(wordPtr + 2)  = 0x0000;
    01530                         *(wordPtr + 3)  = 0x0000;
    01531                         *(wordPtr + 4)  = 0xffff;
    01532                         *(wordPtr + 5)  = 0xffff;
    01533                         *(wordPtr + 6)  = 0xffff;
    01534                         *(wordPtr + 7)  = 0xffff;
    01535                         UNLOCK_DATA(theXlut);
    01536                         theLutData->colorLutWordSize = 16;
    01537                 } else                                                          /*------------------------------------------------ Gray -> Lab */
    01538                 {
    01539                         theXlutSize = (1 << theLutData->colorLutInDim ) * (theLutData->colorLutOutDim) * sizeof(UINT16);
    01540                         theXlut = ALLOC_DATA(theXlutSize + sizeof (UINT16), &aOSerr);
    01541                         err = aOSerr;
    01542                         if (err)
    01543                                 goto CleanupAndExit;
    01544                         LOCK_DATA(theXlut);
    01545                         wordPtr = (UINT16*)DATA_2_PTR(theXlut);
    01546                         *(wordPtr    )  = 0x0000;
    01547                         *(wordPtr + 1)  = 0x0000;
    01548                         *(wordPtr + 2)  = 0x0000;
    01549                         *(wordPtr + 3)  = 0xffff;
    01550                         *(wordPtr + 4)  = 0xffff;
    01551                         *(wordPtr + 5)  = 0xffff;
    01552                         UNLOCK_DATA(theXlut);
    01553                         theLutData->colorLutWordSize = 16;
    01554                 }
    01555         } else
    01556         {
    01557                 if (theCombiData->amIPCS)                       /*------------------------------------------------ XYZ -> Gray */
    01558                 {
    01559                         theLutData->colorLutGridPoints = 3;
    01560                         theXlutSize = (9 * theLutData->colorLutInDim ) * (theLutData->colorLutOutDim) * sizeof(UINT16);
    01561                         theXlut = ALLOC_DATA(theXlutSize + 7*sizeof (UINT16), &aOSerr);
    01562                         err = aOSerr;
    01563                         if (err)
    01564                                 goto CleanupAndExit;
    01565                         LOCK_DATA(theXlut);
    01566                         wordPtr = (UINT16*)DATA_2_PTR(theXlut);
    01567                         for (loop = 0; loop < theLutData->colorLutGridPoints; loop ++)
    01568                         {
    01569                                 *wordPtr++  = 0x0000;
    01570                                 *wordPtr++  = 0x0000;
    01571                                 *wordPtr++  = 0x0000;
    01572                                 *wordPtr++  = 0xffff;
    01573                                 *wordPtr++  = 0xffff;
    01574                                 *wordPtr++  = 0xffff;
    01575                                 *wordPtr++  = 0xffff;
    01576                                 *wordPtr++  = 0xffff;
    01577                                 *wordPtr++  = 0xffff;
    01578                         }
    01579                         UNLOCK_DATA(theXlut);
    01580                         theLutData->colorLutWordSize = 16;
    01581                 } else                                                          /*------------------------------------------------ Gray -> XYZ */
    01582                 {
    01583                         theXlutSize = (1 << theLutData->colorLutInDim ) * (theLutData->colorLutOutDim) * sizeof(UINT16);
    01584                         theXlut = ALLOC_DATA(theXlutSize + sizeof (UINT16), &aOSerr);
    01585                         err = aOSerr;
    01586                         if (err)
    01587                                 goto CleanupAndExit;
    01588                         LOCK_DATA(theXlut);
    01589                         wordPtr = (UINT16*)DATA_2_PTR(theXlut);
    01590                         *(wordPtr    )  = 0x0000;
    01591                         *(wordPtr + 1)  = 0x0000;
    01592                         *(wordPtr + 2)  = 0x0000;
    01593                         *(wordPtr + 3)  = 0x0f6d5 / 2;
    01594                         *(wordPtr + 4)  = 0x0ffff / 2;
    01595                         *(wordPtr + 5)  = 0x0d3c2 / 2;
    01596                         UNLOCK_DATA(theXlut);
    01597                         theLutData->colorLutWordSize = 16;
    01598                 }
    01599         }
    01600
    01601         /* ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
    01602                                                                                                         E l u t
    01603            ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/
    01604         theElutSize = (1<<adr_breite_elut) * sizeof (UINT16);
    01605         theElut = ALLOC_DATA(theElutSize * theLutData->colorLutInDim + sizeof (UINT16), &aOSerr);
    01606         err = aOSerr;
    01607         if (err)
    01608                 goto CleanupAndExit;
    01609         LOCK_DATA(theElut);
    01610
    01611         if (theCombiData->amIPCS)
    01612         {
    01613                 /* -----------------------------------------------------------------------------
    01614                         if PCS -> create Elut
    01615                    -----------------------------------------------------------------------------*/
    01616                 if ( theCombiData->doCreate_16bit_ELut )                                        /* this is NOT the first Elut */
    01617                 {
    01618                         CreateLinearElut16 ( (Ptr)DATA_2_PTR(theElut), theElutSize / sizeof(UINT16), theLutData->colorLutGridPoints, 0);
    01619                         theLutData->inputLutEntryCount = theElutSize / sizeof(UINT16);
    01620                         theLutData->inputLutWordSize = VAL_USED_BITS;
    01621                 }
    01622         else                                                                                                            /* this is the first Elut*/
    01623         {
    01624                 if ( theCombiData->doCreate_16bit_Combi )       /* UWE 9.2.96 */
    01625                 {
    01626                     CreateLinearElut16 ( (Ptr)DATA_2_PTR(theElut), theElutSize / sizeof(UINT16), theCombiData->gridPointsCube, 0);
    01627                     theLutData->inputLutWordSize = VAL_USED_BITS;
    01628                 }
    01629                 else
    01630                         {
    01631                                 CreateLinearElut ( (Ptr)DATA_2_PTR(theElut), theElutSize / sizeof(UINT16), theCombiData->gridPointsCube, 0);
    01632                                 theLutData->inputLutWordSize = bit_breite_elut;
    01633                         }
    01634                 theLutData->inputLutEntryCount = theElutSize / sizeof(UINT16);
    01635                 }
    01636         }
    01637         else
    01638         {
    01639                 /* -----------------------------------------------------------------------------
    01640                         ... else get Elut from TRC tag
    01641                    -----------------------------------------------------------------------------*/
    01642                 if ( theCombiData->doCreate_16bit_ELut  )                                       /* this is NOT the first Elut */
    01643                 {
    01644                         err = Fill_ushort_ELUT_from_CurveTag(pCurveTag, (UINT16*)DATA_2_PTR(theElut), adr_breite_elut, VAL_USED_BITS, theLutData->colorLutGridPoints);
    01645                         theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    01646                         theLutData->inputLutWordSize = VAL_USED_BITS;
    01647                 }
    01648                 else                                                                                                            /* this is the first Elut */
    01649                 {
    01650                 if ( theCombiData->doCreate_16bit_Combi )               /* UWE 9.2.96 */
    01651                 {
    01652                     err = Fill_ushort_ELUT_from_CurveTag(pCurveTag, (UINT16*)DATA_2_PTR(theElut), adr_breite_elut, VAL_USED_BITS, theCombiData->gridPointsCube);
    01653                     theLutData->inputLutWordSize = VAL_USED_BITS;
    01654                         }
    01655                 else
    01656                 {
    01657                     err = Fill_ushort_ELUT_from_CurveTag(pCurveTag, (UINT16*)DATA_2_PTR(theElut), adr_breite_elut, bit_breite_elut, theCombiData->gridPointsCube);
    01658                     theLutData->inputLutWordSize = bit_breite_elut;
    01659                         }
    01660             theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    01661                 }
    01662
    01663         }
    01664         for (loop = 1; loop < (theLutData->colorLutInDim); loop++)
    01665                 BlockMoveData(DATA_2_PTR(theElut), (Ptr)DATA_2_PTR(theElut) + loop * theElutSize, theElutSize);
    01666         UNLOCK_DATA(theElut);
    01667
    01668         /* ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
    01669                                                                                                         A l u t
    01670            ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/
    01671         if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi ) /* UWE 9.2.96*/
    01672                 theSize = sizeof(UINT16);
    01673         else
    01674                 theSize = sizeof(UINT8);
    01675
    01676         theAlutSize = (1<<adr_breite_alut);
    01677         theAlut = ALLOC_DATA(theLutData->colorLutOutDim * theAlutSize * theSize + theSize, &aOSerr);
    01678         err = aOSerr;
    01679         if (err)
    01680                 goto CleanupAndExit;
    01681
    01682         LOCK_DATA(theAlut);
    01683         if (theCombiData->amIPCS)
    01684         {
    01685                 /* -----------------------------------------------------------------------------
    01686                         if PCS -> get Alut from TRC tag
    01687                    -----------------------------------------------------------------------------*/
    01688                 if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi )  /*  UWE 9.2.96                  this is NOT the last Alut*/
    01689                 {
    01690                         err = Fill_inverse_ushort_ALUT_from_CurveTag( pCurveTag, (UINT16*)DATA_2_PTR(theAlut), adr_breite_alut);
    01691                         if (err)
    01692                                 goto CleanupAndExit;
    01693                         theLutData->outputLutEntryCount = (SINT16)theAlutSize;
    01694                         theLutData->outputLutWordSize = VAL_USED_BITS;
    01695                 }
    01696                 else                                                                                                                    /* this is the last Alut */
    01697                 {
    01698                         err = Fill_inverse_byte_ALUT_from_CurveTag( pCurveTag, (UINT8*)DATA_2_PTR(theAlut), adr_breite_alut);
    01699                         if (err)
    01700                                 goto CleanupAndExit;
    01701                         theLutData->outputLutEntryCount = (SINT16)theAlutSize;
    01702                         theLutData->outputLutWordSize = bit_breite_alut;
    01703                 }
    01704         } else
    01705         {
    01706                 /* -----------------------------------------------------------------------------
    01707                         ... else create linear Alut
    01708                    -----------------------------------------------------------------------------*/
    01709                 if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi )  /* UWE 9.2.96                   this is NOT the last Alut */
    01710                 {
    01711                         CreateLinearAlut16 ( (UINT16 *)DATA_2_PTR(theAlut), theAlutSize);
    01712                         theLutData->outputLutEntryCount = (SINT16)theAlutSize;
    01713                         theLutData->outputLutWordSize = VAL_USED_BITS;
    01714                         if ( theCombiData->profileConnectionSpace == icSigLabData )
    01715                                 SetMem16((Ptr)DATA_2_PTR(theAlut) + theAlutSize * theSize, (theLutData->colorLutOutDim -1 ) * theAlutSize, 0x08000);
    01716                         else
    01717                         {
    01718                                 for (loop = 1; loop < theLutData->colorLutOutDim; loop++)
    01719                                         BlockMoveData(DATA_2_PTR(theAlut), (Ptr)DATA_2_PTR(theAlut) + loop * theAlutSize * sizeof(UINT16), theAlutSize * sizeof(UINT16));
    01720                         }
    01721                 }
    01722                 else                                                                                                            /* this is the last Alut */
    01723                 {
    01724                         CreateLinearAlut ( (UINT8 *)DATA_2_PTR(theAlut), theAlutSize);
    01725                         theLutData->outputLutEntryCount = theAlutSize;
    01726                         theLutData->outputLutWordSize = VAL_USED_BITS;
    01727                         if ( theCombiData->profileConnectionSpace == icSigLabData )
    01728                                 SetMem((Ptr)DATA_2_PTR(theAlut) + theAlutSize * theSize, (theLutData->colorLutOutDim -1 ) * theAlutSize * theSize, 0x080);
    01729                         else
    01730                         {
    01731                                 for (loop = 1; loop < theLutData->colorLutOutDim; loop++)
    01732                                         BlockMoveData(DATA_2_PTR(theAlut), (Ptr)DATA_2_PTR(theAlut) + loop * theAlutSize, theAlutSize);
    01733                         }
    01734                 }
    01735         }
    01736         UNLOCK_DATA(theAlut);
    01737
    01738         /* --------------------------------------------------------------------------------- */
    01739         theLutData->inputLut = theElut; theElut = nil;
    01740         theLutData->outputLut = theAlut; theAlut = nil;
    01741         theLutData->colorLut = theXlut; theXlut = nil;
    01742
    01743         /* ---------------------------------------------------------------------------------
    01744             clean up
    01745            --------------------------------------------------------------------------------- */
    01746 CleanupAndExit:
    01747         pCurveTag       = (icCurveType*)DisposeIfPtr((Ptr)pCurveTag);
    01748         theElut         =  DISPOSE_IF_DATA(theElut);
    01749         theAlut         =  DISPOSE_IF_DATA(theAlut);
    01750         theXlut         =  DISPOSE_IF_DATA(theXlut);
    01751
    01752         LH_END_PROC("Extract_Gray_Luts")
    01753         return err;
    01754 }

CMError Extract_MFT_Alut | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData,
|  | Ptr | profileLutPtr,
|  | OSType | theTag
| ) |

Definition at line 830 of file lh_core/genluts.c.

References adr_bereich_alut, adr_breite_alut, bit_breite_alut, Boolean, CMError, CMGetPartialProfileElement(), cmProfileError, CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, DisposeIfPtr(), LHCombiData::doCreate_16bit_ALut, LHCombiData::doCreate_16bit_Combi, FALSE, Fill_byte_ALUTs_from_lut16Tag(), Fill_byte_ALUTs_from_lut8Tag(), Fill_ushort_ALUTs_from_lut16Tag(), Fill_ushort_ALUTs_from_lut8Tag(), icSigLut8Type, LH_END_PROC, LH_START_PROC, nil, noErr, OSErr, OSType, CMLutParam::outputLutEntryCount, CMLutParam::outputLutWordSize, Ptr, SINT16, SINT32, SmartNewPtr(), LHCombiData::theProfile, TRUE, UINT16, UINT32, and VAL_USED_BITS.

Referenced by ExtractAll_MFT_Luts(), and MakeSessionFromLink().

    00834 {
    00835         CMError         err = noErr;
    00836         OSErr           aOSerr = noErr;
    00837         UINT32          byteCount;
    00838         SINT32          offset;
    00839         SINT32          clutSize;
    00840         SINT32          i;
    00841         SINT32          inputTableEntries;
    00842         SINT32          outputTableEntries;
    00843         Ptr                     theOutputLuts   = nil;  /* ¥¥¥12/1/95;*/
    00844         Boolean         readLutFromFile = TRUE;
    00845         UINT16*         shortPtr;
    00846
    00847         LH_START_PROC("Extract_MFT_Alut")
    00848
    00849         clutSize = theLutData->colorLutOutDim;
    00850         for(i=0; i<theLutData->colorLutInDim; i++)
    00851                 clutSize *= theLutData->colorLutGridPoints;
    00852         /* ============================================================================================================================
    00853                                                                                                                                  mft1
    00854            ============================================================================================================================ */
    00855         if ( *((OSType*)profileLutPtr) == icSigLut8Type )
    00856         {
    00857                 /* --------------------------------------------------------------------------------- get outputLuts out of the profile */
    00858                 inputTableEntries  = 256;
    00859                 outputTableEntries = 256;
    00860                 offset                     = 48 + (inputTableEntries * theLutData->colorLutInDim) + clutSize;
    00861                 byteCount = theLutData->colorLutOutDim * outputTableEntries;
    00862         theOutputLuts = SmartNewPtr(byteCount, &aOSerr);
    00863                 err = aOSerr;
    00864                 if (err)
    00865                         goto CleanupAndExit;
    00866                 err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, theOutputLuts);
    00867                 if (err)
    00868                         goto CleanupAndExit;
    00869                 if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi )  /* this is NOT the last Alut*/
    00870                 {
    00871                         err = Fill_ushort_ALUTs_from_lut8Tag( theLutData, theOutputLuts, adr_breite_alut);
    00872                         if (err)
    00873                                 goto CleanupAndExit;
    00874                         theLutData->outputLutEntryCount = adr_bereich_alut;
    00875                         theLutData->outputLutWordSize = VAL_USED_BITS;
    00876                 }
    00877                 else                                                                                                                                                    /* this is the last Alut */
    00878                 {
    00879                         err = Fill_byte_ALUTs_from_lut8Tag( theLutData, theOutputLuts, adr_breite_alut);
    00880                         if (err)
    00881                                 goto CleanupAndExit;
    00882                         theLutData->outputLutEntryCount = adr_bereich_alut;
    00883                         theLutData->outputLutWordSize = bit_breite_alut;
    00884                 }
    00885         }
    00886         /* ============================================================================================================================
    00887                                                                                                                                  mft2
    00888            ============================================================================================================================ */
    00889         else
    00890         {
    00891                 /* --------------------------------------------------------------------------------- get outputLuts out of the profile */
    00892                 inputTableEntries       = ((icLut16Type *)profileLutPtr)->lut.inputEnt;
    00893                 if (inputTableEntries <2)
    00894                 {
    00895 #if realThing
    00896                         err = cmProfileError;
    00897                         goto CleanupAndExit;
    00898 #endif
    00899                 }
    00900                 outputTableEntries      = ((icLut16Type *)profileLutPtr)->lut.outputEnt;
    00901                 if (outputTableEntries <2)
    00902                 {
    00903 #if ! realThing
    00904                         readLutFromFile = FALSE;
    00905                         outputTableEntries = 2;
    00906 #else
    00907                         err = cmProfileError;
    00908                         goto CleanupAndExit;
    00909 #endif
    00910                 }
    00911                 if (readLutFromFile)
    00912                 {
    00913                         offset          = 52 + (( inputTableEntries * theLutData->colorLutInDim) + clutSize) * sizeof(UINT16);
    00914                         byteCount       = theLutData->colorLutOutDim * outputTableEntries * sizeof(UINT16);
    00915                 theOutputLuts = SmartNewPtr(byteCount, &aOSerr);
    00916                         err = aOSerr;
    00917                         if (err)
    00918                                 goto CleanupAndExit;
    00919                         err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, theOutputLuts);
    00920                         if (err)
    00921                                 goto CleanupAndExit;
    00922 #ifdef IntelMode
    00923            SwapShortOffset( theOutputLuts, 0, byteCount );
    00924 #endif
    00925                 } else
    00926                 {
    00927                         theOutputLuts = SmartNewPtr(2 * sizeof(SINT16) * theLutData->colorLutOutDim, &aOSerr);
    00928                         err = aOSerr;
    00929                         if (err)
    00930                                 goto CleanupAndExit;
    00931                         shortPtr = (UINT16*)theOutputLuts;
    00932                         for (i = 0; i< ( theLutData->colorLutOutDim * outputTableEntries ); i+=outputTableEntries)
    00933                         {
    00934                                 shortPtr[i]     = 0;
    00935                                 shortPtr[i+1]   = (UINT16)0xFFFF;
    00936                         }
    00937                 }
    00938                 if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi )/*  UWE 9.2.96    this is NOT the last Alut */
    00939                 {
    00940                         err = Fill_ushort_ALUTs_from_lut16Tag( theLutData, theOutputLuts, adr_breite_alut, outputTableEntries);
    00941                         if (err)
    00942                                 goto CleanupAndExit;
    00943                         theLutData->outputLutEntryCount = adr_bereich_alut;
    00944                         theLutData->outputLutWordSize = VAL_USED_BITS;
    00945                 }
    00946                 else                                                                                                            /*  this is the last Alut */
    00947                 {
    00948                         err = Fill_byte_ALUTs_from_lut16Tag( theLutData, theOutputLuts, adr_breite_alut, outputTableEntries);
    00949                         if (err)
    00950                                 goto CleanupAndExit;
    00951                         theLutData->outputLutEntryCount = adr_bereich_alut;
    00952                         theLutData->outputLutWordSize = bit_breite_alut;
    00953                 }
    00954         }
    00955
    00956         /*---------------------------------------------------------------------------------
    00957            clean up & exit
    00958           ---------------------------------------------------------------------------------*/
    00959 CleanupAndExit:
    00960         theOutputLuts = DisposeIfPtr(theOutputLuts);
    00961
    00962         LH_END_PROC("Extract_MFT_Alut")
    00963         return err;
    00964 }

CMError Extract_MFT_Elut | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData,
|  | Ptr | profileLutPtr,
|  | OSType | theTag
| ) |

Definition at line 512 of file lh_core/genluts.c.

References adr_breite_elut, bit_breite_elut, Boolean, CMError, CMGetPartialProfileElement(), cmProfileError, CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, DisposeIfPtr(), LHCombiData::doCreate_16bit_Combi, LHCombiData::doCreate_16bit_ELut, LHCombiData::doCreateLinkProfile, FALSE, Fill_ushort_ELUTs_from_lut16Tag(), Fill_ushort_ELUTs_from_lut8Tag(), LHCombiData::gridPointsCube, icSigLut8Type, CMLutParam::inputLutEntryCount, CMLutParam::inputLutWordSize, LH_END_PROC, LH_START_PROC, LHCombiData::maxProfileCount, nil, noErr, OSErr, OSType, LHCombiData::profLoop, Ptr, SINT16, SINT32, SmartNewPtr(), LHCombiData::theProfile, TRUE, UINT16, UINT32, and VAL_USED_BITS.

Referenced by ExtractAll_MFT_Luts(), and MakeSessionFromLink().

    00516 {
    00517         CMError         err = noErr;
    00518         OSErr           aOSerr = noErr;
    00519         UINT32          byteCount;
    00520         SINT32          offset;
    00521         SINT32          i;
    00522         SINT32          inputTableEntries;
    00523         Ptr                     theInputLuts    = nil;          /*¥¥¥12/1/95*/
    00524         Boolean         readLutFromFile = TRUE;
    00525         UINT16*         shortPtr;
    00526
    00527         LH_START_PROC("Extract_MFT_Elut")
    00528
    00529         /* ============================================================================================================================
    00530                                                                                                                                  mft1
    00531            ============================================================================================================================ */
    00532         if ( *((OSType*)profileLutPtr) == icSigLut8Type )
    00533         {
    00534                 /* --------------------------------------------------------------------------------- get inputLuts out of the profile */
    00535                 inputTableEntries       = 256;
    00536                 offset                          = 48;   /* input luts for mft1 start at byte 48 */
    00537                 byteCount                       = theLutData->colorLutInDim * inputTableEntries;
    00538                 theInputLuts = SmartNewPtr(byteCount, &aOSerr);
    00539                 err = aOSerr;
    00540                 if (err)
    00541                         goto CleanupAndExit;
    00542                 err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, theInputLuts);
    00543                 if (err)
    00544                         goto CleanupAndExit;
    00545                 if ( theCombiData->doCreate_16bit_ELut )        /* this is NOT the first Elut -or- doCreateLinkProfile */
    00546                 {
    00547                                                                                                                                                 /* if we create a LinkProfile the Elut should not be scaled... */
    00548                         if ((theCombiData->doCreateLinkProfile) && (theCombiData->profLoop == 0))
    00549                                 err = Fill_ushort_ELUTs_from_lut8Tag( theLutData, theInputLuts, adr_breite_elut, bit_breite_elut, 0 );
    00550                         else                                                                                                            /* else scale Elut to gridpoints in profile... */
    00551                                 err = Fill_ushort_ELUTs_from_lut8Tag( theLutData, theInputLuts, adr_breite_elut, VAL_USED_BITS, theLutData->colorLutGridPoints );
    00552                         theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    00553                         theLutData->inputLutWordSize = VAL_USED_BITS;
    00554                 }
    00555                 else                                                                                                                    /* this is the first Elut */
    00556                 {
    00557             if ( theCombiData->doCreate_16bit_Combi )   /* UWE 9.2.96 */
    00558                 {
    00559                     if (theCombiData->maxProfileCount == 0)                                     /* if we have only one profile, the scale Elut to gridpoints in profile...*/
    00560                         err = Fill_ushort_ELUTs_from_lut8Tag( theLutData, theInputLuts, adr_breite_elut, VAL_USED_BITS, theLutData->colorLutGridPoints );
    00561                     else                                                                                                        /* else scale Elut to the gridpoints in the cube...*/
    00562                         err = Fill_ushort_ELUTs_from_lut8Tag( theLutData, theInputLuts, adr_breite_elut, VAL_USED_BITS, theCombiData->gridPointsCube );
    00563                         theLutData->inputLutWordSize = VAL_USED_BITS;
    00564             }
    00565             else
    00566             {
    00567                     if (theCombiData->maxProfileCount == 0)                                     /* if we have only one profile, the scale Elut to gridpoints in profile...*/
    00568                         err = Fill_ushort_ELUTs_from_lut8Tag( theLutData, theInputLuts, adr_breite_elut, bit_breite_elut, theLutData->colorLutGridPoints );
    00569                     else                                                                                                        /* else scale Elut to the gridpoints in the cube...*/
    00570                         err = Fill_ushort_ELUTs_from_lut8Tag( theLutData, theInputLuts, adr_breite_elut, bit_breite_elut, theCombiData->gridPointsCube );
    00571                     theLutData->inputLutWordSize = bit_breite_elut;
    00572
    00573             }
    00574             theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    00575                 }
    00576         }
    00577         else
    00578         /* ============================================================================================================================
    00579                                                                                                                                  mft2
    00580            ============================================================================================================================ */
    00581         {
    00582                 /* --------------------------------------------------------------------------------- get inputLuts out of the profile */
    00583                 inputTableEntries       = ((icLut16Type *)profileLutPtr)->lut.inputEnt;
    00584                 if (inputTableEntries <2)
    00585                 {
    00586 #if ! realThing
    00587                         readLutFromFile = FALSE;
    00588                         inputTableEntries = 2;
    00589 #else
    00590                         err = cmProfileError;
    00591                         goto CleanupAndExit;
    00592 #endif
    00593                 }
    00594                 if (readLutFromFile)
    00595                 {
    00596                         offset                          = 52;   /* input luts for mft2 start at byte 52 */
    00597                         byteCount                       = theLutData->colorLutInDim * inputTableEntries * sizeof(UINT16);
    00598                         theInputLuts = SmartNewPtr(byteCount, &aOSerr);
    00599                         err = aOSerr;
    00600                         if (err)
    00601                                 goto CleanupAndExit;
    00602                         err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, theInputLuts);
    00603 #ifdef IntelMode
    00604             SwapShortOffset( theInputLuts, 0, byteCount );
    00605 #endif
    00606                         if (err)
    00607                                 goto CleanupAndExit;
    00608                 } else
    00609                 {
    00610                         theInputLuts = SmartNewPtr(inputTableEntries * sizeof(SINT16) * theLutData->colorLutInDim, &aOSerr);
    00611                         err = aOSerr;
    00612                         if (err)
    00613                                 goto CleanupAndExit;    /* ¥¥¥12/1/95 */
    00614                         shortPtr = (UINT16*)theInputLuts;
    00615                         for (i = 0; i< (theLutData->colorLutInDim * inputTableEntries); i+=inputTableEntries)
    00616                         {
    00617                                 shortPtr[i]     = 0;
    00618                                 shortPtr[i+1]   = 0xFFFF;
    00619                         }
    00620                 }
    00621                 if ( theCombiData->doCreate_16bit_ELut )                                                /* this is NOT the first Elut -or- doCreateLinkProfile */
    00622                 {
    00623                                                                                                                                                 /* if we create a LinkProfile the Elut should not be scaled... */
    00624                         if ((theCombiData->doCreateLinkProfile) && (theCombiData->profLoop == 0))
    00625                                 err = Fill_ushort_ELUTs_from_lut16Tag( theLutData, theInputLuts, adr_breite_elut, VAL_USED_BITS, 0, inputTableEntries );
    00626                         else                                                                                                            /* else scale Elut to gridpoints in profile... */
    00627                                 err = Fill_ushort_ELUTs_from_lut16Tag( theLutData, theInputLuts, adr_breite_elut, VAL_USED_BITS, theLutData->colorLutGridPoints, inputTableEntries );
    00628                         theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    00629                         theLutData->inputLutWordSize = VAL_USED_BITS;
    00630                 }
    00631                 else                                                                                                                    /* this is the first Elut */
    00632                 {
    00633                 if ( theCombiData->doCreate_16bit_Combi )       /* UWE 9.2.96 */
    00634                 {
    00635                     if (theCombiData->maxProfileCount == 0)                                     /* if we have only one profile, the scale Elut to gridpoints in profile...*/
    00636                         err = Fill_ushort_ELUTs_from_lut16Tag( theLutData, theInputLuts, adr_breite_elut, VAL_USED_BITS, theLutData->colorLutGridPoints, inputTableEntries );
    00637                     else                                                                                                        /* else scale Elut to the gridpoints in the cube...*/
    00638                         err = Fill_ushort_ELUTs_from_lut16Tag( theLutData, theInputLuts, adr_breite_elut, VAL_USED_BITS, theCombiData->gridPointsCube, inputTableEntries );
    00639                 theLutData->inputLutWordSize = VAL_USED_BITS;
    00640             }
    00641             else
    00642             {
    00643                     if (theCombiData->maxProfileCount == 0)                                     /* if we have only one profile, the scale Elut to gridpoints in profile...*/
    00644                         err = Fill_ushort_ELUTs_from_lut16Tag( theLutData, theInputLuts, adr_breite_elut, bit_breite_elut, theLutData->colorLutGridPoints, inputTableEntries );
    00645                     else                                                                                                        /* else scale Elut to the gridpoints in the cube...*/
    00646                         err = Fill_ushort_ELUTs_from_lut16Tag( theLutData, theInputLuts, adr_breite_elut, bit_breite_elut, theCombiData->gridPointsCube, inputTableEntries );
    00647                 theLutData->inputLutWordSize = bit_breite_elut;
    00648            }
    00649             theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    00650                 }
    00651         }
    00652         if (err)
    00653                 goto CleanupAndExit;
    00654
    00655         /* ---------------------------------------------------------------------------------
    00656             clean up & exit
    00657            ---------------------------------------------------------------------------------*/
    00658 CleanupAndExit:
    00659         theInputLuts = DisposeIfPtr(theInputLuts);
    00660
    00661         LH_END_PROC("Extract_MFT_Elut")
    00662         return err;
    00663 }

CMError Extract_MFT_Xlut | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData,
|  | Ptr | profileLutPtr,
|  | OSType | theTag
| ) |

Definition at line 673 of file lh_core/genluts.c.

References ALLOC_DATA, CMError, CMGetPartialProfileElement(), cmProfileError, CMLutParam::colorLut, CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, CMLutParam::colorLutWordSize, DATA_2_PTR, DebugPrint, DISPOSE_IF_DATA, DisposeIfPtr(), LHCombiData::doCreate_16bit_XLut, LHCombiData::doCreateLinkProfile, icSigLut8Type, LH_END_PROC, LH_START_PROC, LOCK_DATA, LUT_DATA_TYPE, LHCombiData::maxProfileCount, nil, noErr, OSErr, OSType, Ptr, SINT32, SmartNewPtr(), LHCombiData::theProfile, UINT16, UINT32, UNLOCK_DATA, and VAL_USED_BITS.

Referenced by ExtractAll_MFT_Luts(), and MakeSessionFromLink().

    00677 {
    00678         CMError                 err = noErr;
    00679         OSErr                   aOSerr = noErr;
    00680         SINT32                  i;
    00681         SINT32                  clutSize;
    00682         LUT_DATA_TYPE   localXlut = nil;
    00683         Ptr                             tempXlut   = nil;
    00684         Ptr                             bytePtr   = nil;
    00685         Ptr                             xlutPtr   = nil;
    00686         SINT32                  offset;
    00687         SINT32                  inputTableEntries;
    00688         UINT32                  byteCount;
    00689         UINT32                  theSize;
    00690         UINT32                  aExtraSize;
    00691
    00692         LH_START_PROC("Extract_MFT_Xlut")
    00693
    00694         clutSize = theLutData->colorLutOutDim;
    00695         for(i=0; i<theLutData->colorLutInDim; i++)
    00696                 clutSize *= theLutData->colorLutGridPoints;
    00697
    00698         /* ============================================================================================================================
    00699                                                                                                                                  mft1
    00700            ============================================================================================================================ */
    00701         if ( *((OSType*)profileLutPtr) == icSigLut8Type )
    00702         {
    00703                 if ( theCombiData->maxProfileCount == 0 ){                      /* Link Profile UK13.8.96*/
    00704                         theSize = 1;
    00705                         aExtraSize = 1;
    00706                         for( i=0; i<(theLutData->colorLutInDim-1); ++i){        /* Extra Size for Interpolation */
    00707                                 theSize *= theLutData->colorLutGridPoints;
    00708                                 aExtraSize += theSize;
    00709                         }
    00710 #ifdef ALLOW_MMX
    00711                         aExtraSize++;   /* +1 for MMX 4 Byte access */
    00712 #endif
    00713                 }
    00714                 else{
    00715                         aExtraSize = 0;
    00716                 }
    00717                 aExtraSize *= theLutData->colorLutOutDim;
    00718                 localXlut = ALLOC_DATA(clutSize+aExtraSize, &aOSerr);
    00719         err = aOSerr;
    00720                 if (err)
    00721                         goto CleanupAndExit;
    00722                 LOCK_DATA(localXlut);
    00723                 inputTableEntries       = 256;
    00724                 offset                          = 48 + (inputTableEntries * theLutData->colorLutInDim);
    00725                 byteCount                       = clutSize;
    00726                 err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, DATA_2_PTR(localXlut));
    00727                 theLutData->colorLutWordSize = 8;
    00728                 if (err)
    00729                         goto CleanupAndExit;
    00730         } else
    00731         /* ============================================================================================================================
    00732                                                                                                                                  mft2
    00733            ============================================================================================================================ */
    00734         {
    00735                 if (( theCombiData->maxProfileCount > 0 ) || (theCombiData->doCreateLinkProfile) || (theCombiData->doCreate_16bit_XLut))/* UWE 9.2.96*/
    00736                         clutSize *= 2;
    00737                 if ( theCombiData->maxProfileCount == 0 ){                      /* Link Profile  UK13.8.96*/
    00738                         theSize = 1;
    00739                         aExtraSize = 1;
    00740                         for( i=0; i<(theLutData->colorLutInDim-1); ++i){        /* Extra Size for Interpolation */
    00741                                 theSize *= theLutData->colorLutGridPoints;
    00742                                 aExtraSize += theSize;
    00743                         }
    00744                         if (( theCombiData->doCreateLinkProfile) || (theCombiData->doCreate_16bit_XLut)){
    00745                                 aExtraSize *= 2;
    00746                         }
    00747 #ifdef ALLOW_MMX
    00748                         aExtraSize++;   /* +1 for MMX 4 Byte access */
    00749 #endif
    00750                 }
    00751                 else{
    00752                         aExtraSize = 0;
    00753                 }
    00754                 aExtraSize *= theLutData->colorLutOutDim;
    00755                 localXlut = ALLOC_DATA(clutSize+aExtraSize, &aOSerr);
    00756         err = aOSerr;
    00757                 if (err)
    00758                         goto CleanupAndExit;
    00759                 LOCK_DATA(localXlut);
    00760                 inputTableEntries       = ((icLut16Type *)profileLutPtr)->lut.inputEnt;
    00761                 if (inputTableEntries <2)
    00762                 {
    00763                         err = cmProfileError;
    00764                         goto CleanupAndExit;
    00765                 }
    00766                 offset = 52 + ( inputTableEntries * theLutData->colorLutInDim) * sizeof(UINT16);
    00767
    00768                 if (( theCombiData->maxProfileCount > 0 ) || (theCombiData->doCreateLinkProfile) || (theCombiData->doCreate_16bit_XLut))/* UWE 9.2.96 */
    00769                 {
    00770                         byteCount = clutSize;
    00771                         tempXlut  = 0;
    00772                         err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, DATA_2_PTR(localXlut));
    00773 #ifdef IntelMode
    00774            SwapShortOffset( localXlut, 0, byteCount );
    00775 #endif
    00776                         theLutData->colorLutWordSize = VAL_USED_BITS;
    00777                         if (err)
    00778                                 goto CleanupAndExit;
    00779                 }
    00780                 else
    00781                 {                                                                       /* should only happen with 1 Link profile */
    00782 #ifdef DEBUG_OUTPUT
    00783                         if ( DebugCheck(kThisFile, kDebugMiscInfo) )
    00784                                 DebugPrint("¥ Extract_MFT_Xlut: 1 Link profile mode\n",err);
    00785 #endif
    00786                         byteCount = clutSize * sizeof(UINT16);
    00787                         tempXlut  = SmartNewPtr(byteCount, &aOSerr);
    00788                 err = aOSerr;
    00789                         if (err)
    00790                                 goto CleanupAndExit;
    00791                         err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, tempXlut);
    00792 #ifdef IntelMode
    00793 /*           SwapShortOffset( tempXlut, 0, byteCount ); !! do not swap, take first byte */
    00794 #endif
    00795                         if (err)
    00796                                 goto CleanupAndExit;
    00797                         bytePtr = tempXlut;
    00798                         xlutPtr = (Ptr)DATA_2_PTR(localXlut);
    00799                         for (i = 0; i < clutSize; i++)
    00800                         {
    00801                                 *xlutPtr = *bytePtr;
    00802                                 bytePtr+=2;
    00803                                 xlutPtr++;
    00804                         }
    00805                         theLutData->colorLutWordSize = 8;
    00806                 }
    00807         }
    00808         UNLOCK_DATA(localXlut);
    00809         theLutData->colorLut = localXlut;
    00810         localXlut = nil;
    00811
    00812         /* ---------------------------------------------------------------------------------
    00813             clean up & exit
    00814            ---------------------------------------------------------------------------------*/
    00815 CleanupAndExit:
    00816         localXlut = DISPOSE_IF_DATA(localXlut);
    00817         tempXlut  = DisposeIfPtr(tempXlut);
    00818
    00819         LH_END_PROC("Extract_MFT_Xlut")
    00820         return err;
    00821 }

CMError Extract_TRC_Alut | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData
| ) |

Definition at line 1057 of file lh_core/genluts.c.

References adr_breite_alut, ALLOC_DATA, LHCombiData::amIPCS, icCurveType::base, bit_breite_alut, BlockMoveData, CMError, CMGetProfileElement(), CMLutParam::colorLutOutDim, icCurve::count, CreateLinearAlut(), CreateLinearAlut16(), icCurveType::curve, icCurve::data, DATA_2_PTR, DebugPrint, DISPOSE_IF_DATA, DisposeIfPtr(), LHCombiData::doCreate_16bit_ALut, LHCombiData::doCreate_16bit_Combi, Fill_inverse_byte_ALUT_from_CurveTag(), Fill_inverse_ushort_ALUT_from_CurveTag(), icSigBlueTRCTag, icSigGreenTRCTag, icSigRedTRCTag, kNumOfRGBchannels, LH_END_PROC, LH_START_PROC, LOCK_DATA, LUT_DATA_TYPE, nil, noErr, OSErr, OSType, CMLutParam::outputLut, CMLutParam::outputLutEntryCount, CMLutParam::outputLutWordSize, Ptr, icTagBase::sig, SINT16, SINT32, SINT8, SmartNewPtr(), LHCombiData::theProfile, UINT16, UINT32, UINT8, unimpErr, UNLOCK_DATA, and VAL_USED_BITS.

Referenced by ExtractAll_TRC_Luts().

    01059 {
    01060         OSType                  trcSig[kNumOfRGBchannels];
    01061         icCurveType*    pCurveTag          = nil;
    01062         icCurveType*    invertCurveTag = nil;
    01063         CMError                 err = noErr;
    01064         OSErr                   aOSerr = noErr;
    01065         UINT32                  elementSize;
    01066         SINT32                  loop;
    01067         SINT32                  theSize;
    01068         SINT32                  theAlutSize;
    01069         UINT8                   addrBits;
    01070         LUT_DATA_TYPE   localAlut = nil;
    01071
    01072         LH_START_PROC("Extract_TRC_Alut")
    01073
    01074         /* ---------------------------------------------------- initialization */
    01075         addrBits = adr_breite_alut;
    01076         if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi )/* UWE 9.2.96 */
    01077                 theSize = sizeof(UINT16);
    01078         else
    01079                 theSize = sizeof(UINT8);
    01080         theAlutSize = (1<<addrBits);
    01081         localAlut = ALLOC_DATA(theLutData->colorLutOutDim * theAlutSize * theSize + theSize, &aOSerr);
    01082         err = aOSerr;
    01083         if (err)
    01084         {
    01085 #ifdef DEBUG_OUTPUT
    01086                 if ( err && DebugCheck(kThisFile, kDebugErrorInfo) )
    01087                         DebugPrint("¥ Extract_TRC_Alut ALLOC_DATA(%d * %d) error\n",theLutData->colorLutOutDim , theAlutSize);
    01088 #endif
    01089                 goto CleanupAndExit;
    01090         }
    01091         LOCK_DATA(localAlut);
    01092         if (!theCombiData->amIPCS)
    01093         {
    01094                 /* ---------------------------------------------------------------------------------
    01095                                 if NOT PCS -> create linear Alut ...
    01096                    ---------------------------------------------------------------------------------*/
    01097                 if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi )/* UWE 9.2.96             this is NOT the last Alut */
    01098                 {
    01099                         CreateLinearAlut16 ( (UINT16 *)DATA_2_PTR(localAlut),theAlutSize);
    01100                         for (loop = 0; loop < theLutData->colorLutOutDim; loop++)
    01101                                 BlockMoveData(DATA_2_PTR(localAlut), (Ptr)DATA_2_PTR(localAlut) + loop * theAlutSize * sizeof(UINT16), theAlutSize * sizeof(UINT16));
    01102                         theLutData->outputLutEntryCount = (SINT16)theAlutSize;
    01103                         theLutData->outputLutWordSize = VAL_USED_BITS;
    01104                 }
    01105                 else                                                                                                    /* this is NOT the last Alut */
    01106                 {
    01107                         CreateLinearAlut ( (UINT8 *)DATA_2_PTR(localAlut),theAlutSize);
    01108                         for (loop = 0; loop < theLutData->colorLutOutDim; loop++)
    01109                                 BlockMoveData(DATA_2_PTR(localAlut), (Ptr)DATA_2_PTR(localAlut) + loop * theAlutSize, theAlutSize);
    01110                         theLutData->outputLutEntryCount = (SINT16)theAlutSize;
    01111                         theLutData->outputLutWordSize = 8;
    01112                 }
    01113         }
    01114         else
    01115         {
    01116                 /* ---------------------------------------------------------------------------------
    01117                         ... else take TRCs for Aluts
    01118                    ---------------------------------------------------------------------------------*/
    01119                 trcSig[0] = icSigRedTRCTag;
    01120                 trcSig[1] = icSigGreenTRCTag;
    01121                 trcSig[2] = icSigBlueTRCTag;
    01122
    01123                 for (loop = 0; loop < kNumOfRGBchannels; loop++)
    01124                 {
    01125                         err = CMGetProfileElement(theCombiData->theProfile, trcSig[loop], &elementSize, nil);
    01126                         if (err)
    01127                                 goto CleanupAndExit;
    01128             pCurveTag = (icCurveType *)SmartNewPtr(elementSize, &aOSerr);
    01129                         err = aOSerr;
    01130                         if (err)
    01131                                 goto CleanupAndExit;
    01132
    01133                         err = CMGetProfileElement(theCombiData->theProfile, trcSig[loop], &elementSize, pCurveTag);
    01134                         if (err){
    01135                                 goto CleanupAndExit;
    01136                         }
    01137 #ifdef IntelMode
    01138             SwapLongOffset( &pCurveTag->base.sig, 0, 4 );
    01139             SwapLong( &pCurveTag->curve.count );
    01140             SwapShortOffset( pCurveTag, (ULONG)((SINT8*)&pCurveTag->curve.data[0]-(SINT8*)pCurveTag), elementSize );
    01141 #endif
    01142                         if (pCurveTag)
    01143                         {
    01144                                 if ( theCombiData->doCreate_16bit_ALut || theCombiData->doCreate_16bit_Combi )  /* UWE 9.2.96            this is NOT the last Alut*/
    01145                                 {
    01146                                         err = Fill_inverse_ushort_ALUT_from_CurveTag( pCurveTag, (UINT16*)DATA_2_PTR(localAlut) + (theAlutSize * loop), addrBits);
    01147                                         if (err)
    01148                                                 goto CleanupAndExit;
    01149                                         theLutData->outputLutEntryCount = (SINT16)theAlutSize;
    01150                                         theLutData->outputLutWordSize = VAL_USED_BITS;
    01151                                 }
    01152                                 else                                                                                            /* this is the last Alut */
    01153                                 {
    01154                                         err = Fill_inverse_byte_ALUT_from_CurveTag( pCurveTag, (UINT8*)DATA_2_PTR(localAlut) + (theAlutSize * loop), addrBits);
    01155                                         if (err)
    01156                                                 goto CleanupAndExit;
    01157                                         theLutData->outputLutEntryCount = (SINT16)theAlutSize;
    01158                                         theLutData->outputLutWordSize = bit_breite_alut;
    01159                                 }
    01160                                 pCurveTag = (icCurveType*)DisposeIfPtr((Ptr)pCurveTag);
    01161                         } else
    01162                         {
    01163                                 err = unimpErr;
    01164                                 goto CleanupAndExit;
    01165                         }
    01166                 }
    01167         }
    01168         UNLOCK_DATA(localAlut);
    01169         /* ----------------------------------------------- no error occured -> save results */
    01170         theLutData->outputLut   = localAlut;
    01171         localAlut = nil;
    01172         /* ---------------------------------------------------------------------------------
    01173             clean up & exit
    01174            ---------------------------------------------------------------------------------*/
    01175 CleanupAndExit:
    01176         localAlut               = DISPOSE_IF_DATA(localAlut);
    01177         pCurveTag               = (icCurveType*)DisposeIfPtr((Ptr)pCurveTag);
    01178
    01179         LH_END_PROC("Extract_TRC_Alut")
    01180         return err;
    01181 }

CMError Extract_TRC_Elut | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData
| ) |

Definition at line 1190 of file lh_core/genluts.c.

References adr_breite_elut, ALLOC_DATA, LHCombiData::amIPCS, icCurveType::base, bit_breite_elut, BlockMoveData, CMError, CMGetProfileElement(), CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, icCurve::count, CreateLinearElut(), CreateLinearElut16(), icCurveType::curve, icCurve::data, DATA_2_PTR, DISPOSE_IF_DATA, DisposeIfPtr(), LHCombiData::doCreate_16bit_Combi, LHCombiData::doCreate_16bit_ELut, LHCombiData::doCreateLinkProfile, Fill_ushort_ELUT_from_CurveTag(), LHCombiData::gridPointsCube, icSigBlueTRCTag, icSigGreenTRCTag, icSigRedTRCTag, CMLutParam::inputLut, CMLutParam::inputLutEntryCount, CMLutParam::inputLutWordSize, kNumOfRGBchannels, LH_END_PROC, LH_START_PROC, LOCK_DATA, LUT_DATA_TYPE, nil, noErr, OSErr, OSType, LHCombiData::profLoop, Ptr, icTagBase::sig, SINT32, SmartNewPtr(), LHCombiData::theProfile, UINT16, UINT32, UNLOCK_DATA, and VAL_USED_BITS.

Referenced by ExtractAll_TRC_Luts().

    01192 {
    01193         OSType                  trcSig[kNumOfRGBchannels];
    01194         icCurveType*    pCurveTag = nil;
    01195         SINT32                  loop;
    01196         SINT32                  theElutSize;
    01197         CMError                 err = noErr;
    01198         OSErr                   aOSerr = noErr;
    01199         UINT32                  elementSize;
    01200         LUT_DATA_TYPE   localElut = nil;
    01201         Ptr                             singleElut = nil;
    01202
    01203         LH_START_PROC("Extract_TRC_Elut")
    01204
    01205         theElutSize =  (1<<adr_breite_elut) * sizeof (UINT16);
    01206         localElut = ALLOC_DATA(theLutData->colorLutInDim * theElutSize + sizeof (UINT16), &aOSerr);
    01207         err = aOSerr;
    01208         if (err)
    01209                 goto CleanupAndExit;
    01210
    01211         /* --------------------------------------------------------------------------------- set gridPoints */
    01212         theLutData->colorLutGridPoints = theCombiData->gridPointsCube;
    01213
    01214         LOCK_DATA(localElut);
    01215         if (theCombiData->amIPCS)
    01216         {
    01217                 /* ---------------------------------------------------------------------------------
    01218                         if PCS -> create linear Elut...
    01219                    --------------------------------------------------------------------------------- */
    01220                 if ( theCombiData->doCreate_16bit_ELut )                                        /* this is NOT the first Elut */
    01221                 {
    01222                         CreateLinearElut16 ( (Ptr)DATA_2_PTR(localElut), theElutSize / sizeof(UINT16), theLutData->colorLutGridPoints, 0);
    01223                         theLutData->inputLutEntryCount = theElutSize / sizeof(UINT16);
    01224                         theLutData->inputLutWordSize = VAL_USED_BITS;
    01225                 }
    01226                 else                                                                                                            /* this is the first Elut */
    01227                 {
    01228                 if ( theCombiData->doCreate_16bit_Combi )                               /* UWE 9.2.96 */
    01229                 {
    01230                 CreateLinearElut16 ( (Ptr)DATA_2_PTR(localElut), theElutSize / sizeof(UINT16), theCombiData->gridPointsCube, 0);
    01231                 theLutData->inputLutWordSize = VAL_USED_BITS;
    01232             }
    01233             else
    01234             {
    01235                 CreateLinearElut ( (Ptr)DATA_2_PTR(localElut), theElutSize / sizeof(UINT16), theCombiData->gridPointsCube, 0);
    01236                 theLutData->inputLutWordSize = bit_breite_elut;
    01237             }
    01238             theLutData->inputLutEntryCount = theElutSize / sizeof(UINT16);
    01239                 }
    01240                 for (loop = 1; loop < theLutData->colorLutInDim; loop++)
    01241                         BlockMoveData(DATA_2_PTR(localElut), (Ptr)DATA_2_PTR(localElut) + loop * theElutSize, theElutSize);
    01242         }
    01243         else
    01244         {
    01245                 /* ---------------------------------------------------------------------------------
    01246                         ... else take TRCs for Eluts
    01247                    --------------------------------------------------------------------------------- */
    01248                 trcSig[0] = icSigRedTRCTag;
    01249                 trcSig[1] = icSigGreenTRCTag;
    01250                 trcSig[2] = icSigBlueTRCTag;
    01251
    01252                 singleElut = SmartNewPtr(theElutSize, &aOSerr);
    01253                 err = aOSerr;
    01254                 if (err)
    01255                         goto CleanupAndExit;
    01256                 for (loop = 0; loop < kNumOfRGBchannels; loop++)
    01257                 {
    01258                         err = CMGetProfileElement(theCombiData->theProfile, trcSig[loop], &elementSize, nil);
    01259                         if (err)
    01260                                 goto CleanupAndExit;
    01261                         pCurveTag = (icCurveType *)SmartNewPtr(elementSize, &aOSerr);
    01262                         err = aOSerr;
    01263                         if (err)
    01264                                 goto CleanupAndExit;
    01265
    01266                         err = CMGetProfileElement(theCombiData->theProfile, trcSig[loop], &elementSize, pCurveTag);
    01267 #ifdef IntelMode
    01268             SwapLongOffset( &pCurveTag->base.sig, 0, 4 );
    01269             SwapLong( &pCurveTag->curve.count );
    01270             SwapShortOffset( pCurveTag, (ULONG)((char*)&pCurveTag->curve.data[0]-(char*)pCurveTag), elementSize );
    01271 #endif
    01272                         if (err)
    01273                                 goto CleanupAndExit;
    01274                         if ( theCombiData->doCreate_16bit_ELut  )               /* this is either NOT the first Elut -or- we have a NewLinkProfile call */
    01275                         {
    01276                                 if ((theCombiData->doCreateLinkProfile) && (theCombiData->profLoop == 0))
    01277                                         err = Fill_ushort_ELUT_from_CurveTag(pCurveTag, (UINT16*)singleElut, adr_breite_elut, VAL_USED_BITS, 0);
    01278                                 else
    01279                                         err = Fill_ushort_ELUT_from_CurveTag(pCurveTag, (UINT16*)singleElut, adr_breite_elut, VAL_USED_BITS, theLutData->colorLutGridPoints);
    01280                                 theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    01281                                 theLutData->inputLutWordSize = VAL_USED_BITS;
    01282                         }
    01283                         else                                                                                                            /* this is the first Elut */
    01284                         {
    01285                         if ( theCombiData->doCreate_16bit_Combi )       /* UWE 9.2.96 */
    01286                         {
    01287                         err = Fill_ushort_ELUT_from_CurveTag(pCurveTag, (UINT16*)singleElut, adr_breite_elut, VAL_USED_BITS, theCombiData->gridPointsCube);
    01288                     theLutData->inputLutWordSize = VAL_USED_BITS;
    01289                 }
    01290                 else
    01291                 {
    01292                         err = Fill_ushort_ELUT_from_CurveTag(pCurveTag, (UINT16*)singleElut, adr_breite_elut, bit_breite_elut, theCombiData->gridPointsCube);
    01293                     theLutData->inputLutWordSize = bit_breite_elut;
    01294                 }
    01295                 theLutData->inputLutEntryCount = (1<<adr_breite_elut);
    01296                         }
    01297                         if (err)
    01298                                 goto CleanupAndExit;
    01299                         BlockMoveData(singleElut, (Ptr)DATA_2_PTR(localElut) + loop * theElutSize, theElutSize);
    01300                         pCurveTag  = (icCurveType *)DisposeIfPtr((Ptr)pCurveTag);
    01301                 }
    01302         }
    01303         /* ----------------------------------------------- no error occured -> save results */
    01304         UNLOCK_DATA(localElut);
    01305         theLutData->inputLut = localElut;
    01306         localElut = nil;
    01307         /* ---------------------------------------------------------------------------------
    01308                 clean up & exit
    01309            --------------------------------------------------------------------------------- */
    01310 CleanupAndExit:
    01311         pCurveTag  = (icCurveType *)DisposeIfPtr((Ptr)pCurveTag);
    01312         localElut  = DISPOSE_IF_DATA(localElut);
    01313         singleElut = DisposeIfPtr(singleElut);
    01314
    01315         LH_END_PROC("Extract_TRC_Elut")
    01316         return err;
    01317 }

CMError Extract_TRC_Matrix | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData
| ) |

Definition at line 1324 of file lh_core/genluts.c.

References LHCombiData::amIPCS, icXYZType::base, BlockMoveData, cmElementTagNotFound, CMError, CMGetProfileElement(), icXYZArray::data, icXYZType::data, doubMatrixInvert(), icAbsoluteColorimetric, icSigBlueColorantTag, icSigGreenColorantTag, icSigMediaWhitePointTag, icSigRedColorantTag, kNumOfRGBchannels, LH_END_PROC, LH_START_PROC, Matrix2D, CMLutParam::matrixTRC, nil, noErr, OSErr, OSType, LHCombiData::renderingIntent, icTagBase::sig, SINT32, SINT8, SmartNewPtr(), LHCombiData::theProfile, and UINT32.

Referenced by ExtractAll_TRC_Luts().

    01326 {
    01327         icXYZType               colorantData[kNumOfRGBchannels];
    01328         icXYZType               curMediaWhite;
    01329         Matrix2D                localMatrix;
    01330         Matrix2D                invertMatrix;
    01331         OSType                  colorantTags[kNumOfRGBchannels];
    01332         CMError                 err = noErr;
    01333         OSErr                   aOSerr = noErr;
    01334         SINT32                  loop;
    01335         SINT32                  i;
    01336         SINT32                  j;
    01337         UINT32                  elementSize;
    01338         double                  factor;
    01339
    01340         LH_START_PROC("Extract_TRC_Matrix")
    01341
    01342         /* -----------------------------------------------------------------initialize */
    01343         colorantTags[0] = icSigRedColorantTag;
    01344         colorantTags[1] = icSigGreenColorantTag;
    01345         colorantTags[2] = icSigBlueColorantTag;
    01346
    01347         /* ---------------------------------------------------------------------------------
    01348                 take Matrix     from profile
    01349            ---------------------------------------------------------------------------------*/
    01350         for (loop = 0; loop < kNumOfRGBchannels; loop++)
    01351         {
    01352                 err = CMGetProfileElement(theCombiData->theProfile, colorantTags[loop], &elementSize, nil);
    01353                 if (err != noErr)
    01354                         goto CleanupAndExit;
    01355                 err = CMGetProfileElement(theCombiData->theProfile, colorantTags[loop], &elementSize, &colorantData[loop]);
    01356 #ifdef IntelMode
    01357         SwapLongOffset( &colorantData[loop].base.sig, 0, 4 );
    01358         SwapLongOffset( &colorantData[loop], (ULONG)((SINT8*)&colorantData[0].data.data[0]-(SINT8*)&colorantData[0]), elementSize );
    01359 #endif
    01360                 if (err != noErr)
    01361                         goto CleanupAndExit;
    01362                 localMatrix[0][loop] = ((double)colorantData[loop].data.data[0].X) / 65536.    / 2.;
    01363                 localMatrix[1][loop] = ((double)colorantData[loop].data.data[0].Y) / 65536.    / 2.;
    01364                 localMatrix[2][loop] = ((double)colorantData[loop].data.data[0].Z) / 65536.    / 2.;
    01365         }
    01366
    01367         if (theCombiData->renderingIntent == icAbsoluteColorimetric)
    01368         {
    01369                 elementSize = sizeof(icXYZType);
    01370                 err = CMGetProfileElement(theCombiData->theProfile, icSigMediaWhitePointTag, &elementSize, &curMediaWhite);
    01371 #ifdef IntelMode
    01372         SwapLongOffset( &curMediaWhite.base.sig, 0, 4 );
    01373         SwapLongOffset( &curMediaWhite, (ULONG)((SINT8*)&curMediaWhite.data.data[0]-(SINT8*)&curMediaWhite), elementSize );
    01374 #endif
    01375                 if (err != cmElementTagNotFound)                /* otherwise take D50 -> do nothing */
    01376                 {
    01377                         if (err != noErr)
    01378                                 goto CleanupAndExit;
    01379
    01380                         for (i=0; i<3; i++)             /* adjust for media white point */
    01381                         {
    01382                                 if (i == 0)                                                                     /* divide X by D50 white X */
    01383                                         factor = ((double)curMediaWhite.data.data[0].X) / 65536. / 0.9642;
    01384                                 else if (i == 1)
    01385                                         factor = ((double)curMediaWhite.data.data[0].Y) / 65536.;
    01386                                 else                                                                            /* divide Z by D50 white Z */
    01387                                         factor = ((double)curMediaWhite.data.data[0].Z) / 65536. / 0.8249;
    01388
    01389                                 for (j=0; j<3; j++)
    01390                                         localMatrix[i][j] *= factor;
    01391                         }
    01392                 }
    01393         }
    01394
    01395         if (theCombiData->amIPCS)
    01396         {
    01397                 doubMatrixInvert(localMatrix, invertMatrix);
    01398                 BlockMoveData(invertMatrix, localMatrix, 9 * sizeof(double));
    01399         }
    01400
    01401         theLutData->matrixTRC = SmartNewPtr(sizeof(Matrix2D), &aOSerr);
    01402         err = aOSerr;
    01403         if (err)
    01404                 goto CleanupAndExit;
    01405         BlockMoveData(localMatrix, theLutData->matrixTRC, sizeof(Matrix2D));
    01406         /* ---------------------------------------------------------------------------------
    01407             clean up & exit
    01408            ---------------------------------------------------------------------------------*/
    01409 CleanupAndExit:
    01410
    01411         LH_END_PROC("Extract_TRC_Matrix")
    01412         return err;
    01413 }

CMError ExtractAll_MFT_Luts | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData,
|  | OSType | theTag
| ) |

Definition at line 973 of file lh_core/genluts.c.

References LHCombiData::amIPCS, CMError, CMGetProfileElement(), CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, LHCombiData::dataColorSpace, DisposeIfPtr(), Extract_MFT_Alut(), Extract_MFT_Elut(), Extract_MFT_Xlut(), GetMatrixFromProfile(), icSigXYZData, LH_END_PROC, LH_START_PROC, nil, noErr, OSErr, LHCombiData::profileConnectionSpace, Ptr, SmartNewPtr(), LHCombiData::theProfile, and UINT32.

Referenced by ExtractAllLuts().

    00976 {
    00977         CMError         err = noErr;
    00978         OSErr           aOSerr = noErr;
    00979         Ptr                     profileLutPtr = nil;
    00980         UINT32          elementSize;
    00981         double          factor;
    00982         UINT32          byteCount;
    00983
    00984         LH_START_PROC("ExtractAll_MFT_Luts")
    00985
    00986         /* -------------------------------------------------------- get partial tag data from profile */
    00987         err = CMGetProfileElement(theCombiData->theProfile, theTag, &elementSize, nil);
    00988         if (err)
    00989                 goto CleanupAndExit;
    00990
    00991         byteCount = 52;                                                                                 /* get the first 52 bytes out of the profile */
    00992         profileLutPtr = SmartNewPtr(byteCount, &aOSerr);
    00993         err = aOSerr;
    00994         if (err)
    00995                 goto CleanupAndExit;
    00996
    00997     err = CMGetProfileElement(theCombiData->theProfile, theTag, &byteCount, profileLutPtr);
    00998 #ifdef IntelMode
    00999     SwapLongOffset( &((icLut16Type*)profileLutPtr)->base.sig, 0, 4 );
    01000     SwapShortOffset( &((icLut16Type*)profileLutPtr)->lut.inputEnt, 0, 2 );
    01001     SwapShortOffset( &((icLut16Type*)profileLutPtr)->lut.outputEnt, 0, 2 );
    01002 #endif
    01003         if (err)
    01004                 goto CleanupAndExit;
    01005
    01006         theLutData->colorLutInDim               = ((icLut8Type*)profileLutPtr)->lut.inputChan;
    01007         theLutData->colorLutOutDim              = ((icLut8Type*)profileLutPtr)->lut.outputChan;
    01008         theLutData->colorLutGridPoints  = ((icLut8Type*)profileLutPtr)->lut.clutPoints;
    01009
    01010         /* ---------------------------------------------------------------------- handle matrix
    01011                 matrix is only used if:
    01012                 ¥ number of input channels is 3 and
    01013                 ¥ input is XYZ
    01014                 matrix is identity for output when pcs == Lab
    01015         */
    01016         if ( ( theLutData->colorLutInDim == 3) &&
    01017                ( (  theCombiData->amIPCS && (theCombiData->profileConnectionSpace == icSigXYZData) ) ||
    01018                  ( !theCombiData->amIPCS && (theCombiData->dataColorSpace                 == icSigXYZData) ) ) )
    01019         {
    01020                 factor = 1.;
    01021                 err = GetMatrixFromProfile(theLutData, theCombiData, theTag, factor);
    01022         }
    01023
    01024         /* ---------------------------------------------------------------------- process A Lut */
    01025         err = Extract_MFT_Alut( theLutData, theCombiData, profileLutPtr, theTag );
    01026         if (err)
    01027                 goto CleanupAndExit;
    01028
    01029         /* ---------------------------------------------------------------------- process X Lut */
    01030         err = Extract_MFT_Xlut ( theLutData, theCombiData, profileLutPtr, theTag );
    01031         if (err)
    01032                 goto CleanupAndExit;
    01033
    01034         /* ---------------------------------------------------------------------- process E Lut */
    01035         err = Extract_MFT_Elut( theLutData, theCombiData, profileLutPtr, theTag );
    01036         if (err)
    01037                 goto CleanupAndExit;
    01038
    01039         /* ---------------------------------------------------------------------------------
    01040                  clean up
    01041            ---------------------------------------------------------------------------------*/
    01042 CleanupAndExit:
    01043         profileLutPtr = DisposeIfPtr(profileLutPtr);
    01044
    01045         LH_END_PROC("ExtractAll_MFT_Luts")
    01046         return err;
    01047 }

CMError ExtractAll_TRC_Luts | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData
| ) |

Definition at line 1421 of file lh_core/genluts.c.

References CMError, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, Extract_TRC_Alut(), Extract_TRC_Elut(), Extract_TRC_Matrix(), kNumOfRGBchannels, LH_END_PROC, LH_START_PROC, and noErr.

Referenced by ExtractAllLuts().

    01423 {
    01424         CMError err = noErr;
    01425
    01426         LH_START_PROC("ExtractAll_TRC_Luts")
    01427
    01428         theLutData->colorLutInDim = kNumOfRGBchannels;
    01429         theLutData->colorLutOutDim = kNumOfRGBchannels;
    01430
    01431         /* ------------------------------------------------------------------------- process A lut */
    01432         err = Extract_TRC_Alut( theLutData, theCombiData);
    01433         if (err != noErr)
    01434                 goto CleanupAndExit;
    01435
    01436         /* ------------------------------------------------------------------------- process matrix */
    01437         err = Extract_TRC_Matrix ( theLutData, theCombiData);
    01438         if (err != noErr)
    01439                 goto CleanupAndExit;
    01440
    01441         /* ------------------------------------------------------------------------- process E lut */
    01442         err = Extract_TRC_Elut( theLutData, theCombiData);
    01443         if (err != noErr)
    01444                 goto CleanupAndExit;
    01445
    01446         /* ---------------------------------------------------------------------------------
    01447             clean up
    01448            ---------------------------------------------------------------------------------*/
    01449 CleanupAndExit:
    01450
    01451         LH_END_PROC("ExtractAll_TRC_Luts")
    01452         return err;
    01453 }

CMError ExtractAllLuts | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData
| ) |

Definition at line 1762 of file lh_core/genluts.c.

References LHCombiData::amIPCS, CMError, cmProfileError, LHCombiData::dataColorSpace, DebugPrint, LHCombiData::doCreateGamutLut, DoMakeGamutForMonitor(), Extract_Gray_Luts(), ExtractAll_MFT_Luts(), ExtractAll_TRC_Luts(), icAbsoluteColorimetric, icPerceptual, icRelativeColorimetric, icSaturation, icSigAbstractClass, icSigAToB0Tag, icSigAToB1Tag, icSigAToB2Tag, icSigBToA0Tag, icSigBToA1Tag, icSigBToA2Tag, icSigCmykData, icSigColorSpaceClass, icSigDisplayClass, icSigGamutTag, icSigGrayData, icSigInputClass, icSigLinkClass, icSigOutputClass, icSigPreview0Tag, icSigPreview1Tag, icSigPreview2Tag, icSigRgbData, icSigXYZData, LH_END_PROC, LH_START_PROC, noErr, OSType, LHCombiData::profileClass, LHCombiData::profileConnectionSpace, LHCombiData::renderingIntent, and LHCombiData::usePreviewTag.

Referenced by CreateCombi().

    01764 {
    01765         CMError         err = noErr;
    01766         OSType          theTag;
    01767
    01768         LH_START_PROC("ExtractAllLuts")
    01769
    01770         /* --------------------------------------------------------------------------------- find out what tag to use... */
    01771         if ( theCombiData->doCreateGamutLut )
    01772                 theTag = icSigGamutTag;
    01773         else
    01774         {
    01775                 switch (theCombiData->renderingIntent)
    01776                 {
    01777                         case icPerceptual:                              /* Photographic images */
    01778                                 if (theCombiData->usePreviewTag)
    01779                                         theTag = icSigPreview0Tag;
    01780                                 else
    01781                                 {
    01782                                         if (theCombiData->amIPCS)
    01783                                                 theTag = icSigBToA0Tag;
    01784                                         else
    01785                                                 theTag = icSigAToB0Tag;
    01786                                 }
    01787                                 break;
    01788                         case icRelativeColorimetric:    /* Logo Colors */
    01789                                 if (theCombiData->usePreviewTag)
    01790                                         theTag = icSigPreview1Tag;
    01791                                 else
    01792                                 {
    01793                                         if (theCombiData->amIPCS)
    01794                                                 theTag = icSigBToA1Tag;
    01795                                         else
    01796                                                 theTag = icSigAToB1Tag;
    01797                                 }
    01798                                 break;
    01799                         case icSaturation:                              /* Business graphics */
    01800                                 if (theCombiData->usePreviewTag)
    01801                                         theTag = icSigPreview2Tag;
    01802                                 else
    01803                                 {
    01804                                         if (theCombiData->amIPCS)
    01805                                                 theTag = icSigBToA2Tag;
    01806                                         else
    01807                                                 theTag = icSigAToB2Tag;
    01808                                 }
    01809                                 break;
    01810                         case icAbsoluteColorimetric:    /* Logo Colors */
    01811                                 if (theCombiData->usePreviewTag)
    01812                                         theTag = icSigPreview1Tag;
    01813                                 else
    01814                                 {
    01815                                         if (theCombiData->amIPCS)
    01816                                                 theTag = icSigBToA1Tag;
    01817                                         else
    01818                                                 theTag = icSigAToB1Tag;
    01819                                 }
    01820                                 break;
    01821                         default:
    01822                                 err = cmProfileError;
    01823                                 break;
    01824                 }
    01825         }
    01826 #ifdef DEBUG_OUTPUT
    01827         if ( DebugCheck(kThisFile, kDebugMiscInfo) )
    01828                 DebugPrint("  ExtractAllLuts: theTag = '%4.4s'=0x%08X (renderingIntent = %d)\n",  &theTag, theTag, theCombiData->renderingIntent );
    01829 #endif
    01830
    01831         switch (theCombiData->profileClass)
    01832         {
    01833                 /* ---------------------------------------------------------------------------------
    01834                         input profile
    01835                    ---------------------------------------------------------------------------------*/
    01836                 case icSigInputClass:
    01837                         switch (theCombiData->dataColorSpace)
    01838                         {
    01839                                 case icSigGrayData:                                                                                                                                             /*  Gray Input Profile */
    01840                                         err = Extract_Gray_Luts( theLutData, theCombiData);
    01841                                         break;
    01842                                 case icSigRgbData:                                                                                                                                                      /*  RGB Input Profile */
    01843                                         err = ExtractAll_MFT_Luts( theLutData, theCombiData, theTag );
    01844                                         if ( err != noErr && theCombiData->renderingIntent != icPerceptual )
    01845                                         {
    01846                                                 if (theCombiData->amIPCS)
    01847                                                         theTag = icSigBToA0Tag;
    01848                                                 else
    01849                                                         theTag = icSigAToB0Tag;
    01850 #ifdef DEBUG_OUTPUT
    01851                                                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    01852                                                         DebugPrint("Æ 'scnr': ExtractAll_MFT_Luts failed - continuing with '%4.4s'...\n", &theTag);
    01853 #endif
    01854                                                 err = ExtractAll_MFT_Luts( theLutData, theCombiData, theTag );
    01855                                         }
    01856                                         if (( err != noErr ) && (theCombiData->profileConnectionSpace == icSigXYZData ))
    01857                                         {
    01858                                                 /* XYZ and no mft -> try matrix/TRC: */
    01859 #ifdef DEBUG_OUTPUT
    01860                                                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    01861                                                         DebugPrint("Æ 'scnr': ExtractAll_MFT_Luts failed - continuing with TRC...\n");
    01862 #endif
    01863                                                 err = ExtractAll_TRC_Luts( theLutData, theCombiData );
    01864                                         }
    01865                                         break;
    01866                                 case icSigCmykData:                                                                                                                                             /* CMYK */
    01867                                         err = ExtractAll_MFT_Luts( theLutData, theCombiData, theTag );
    01868                                         if ( err != noErr && theCombiData->renderingIntent != icPerceptual )
    01869                                         {
    01870                                                 if (theCombiData->amIPCS)
    01871                                                         theTag = icSigBToA0Tag;
    01872                                                 else
    01873                                                         theTag = icSigAToB0Tag;
    01874 #ifdef DEBUG_OUTPUT
    01875                                                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    01876                                                         DebugPrint("Æ 'scnr': ExtractAll_MFT_Luts failed - continuing with '%4.4s'...\n", &theTag);
    01877 #endif
    01878                                                 err = ExtractAll_MFT_Luts( theLutData, theCombiData, theTag );
    01879                                         }
    01880                                         break;
    01881                                 default:                                                                                                                                                                /* this covers also: cmHSVData, cmHLSData, cmCMYData */
    01882                                         /* CMYK Input Profile must have an A2B0Tag (see page 17 InterColor Profile Format) */
    01883                                         if (theCombiData->amIPCS)
    01884                                                 theTag = icSigBToA0Tag;
    01885                                         else
    01886                                                 theTag = icSigAToB0Tag;
    01887                                         err = ExtractAll_MFT_Luts( theLutData, theCombiData, theTag );
    01888                                         break;
    01889                         }
    01890                         break;
    01891                 /* ---------------------------------------------------------------------------------
    01892                         display profile
    01893                    ---------------------------------------------------------------------------------*/
    01894                 case icSigDisplayClass:
    01895                         switch (theCombiData->dataColorSpace)
    01896                         {
    01897                                 case icSigGrayData:                                                                                                                                             /*  Gray display Profile */
    01898                                         err = Extract_Gray_Luts( theLutData, theCombiData);
    01899                                         break;
    01900                                 case icSigRgbData:                                                                                                                                                      /*  RGB display Profile */
    01901                                         if ( theCombiData->doCreateGamutLut)
    01902                                         {
    01903                                                 err = DoMakeGamutForMonitor( theLutData, theCombiData );
    01904                                         } else
    01905                                         {
    01906                                                 err = ExtractAll_MFT_Luts(theLutData, theCombiData, theTag);
    01907                                                 if (( err != noErr ) && (theCombiData->profileConnectionSpace == icSigXYZData ))
    01908                                                 {
    01909                                                         /* XYZ and no mft -> try matrix/TRC: */
    01910 #ifdef DEBUG_OUTPUT
    01911                                                         if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    01912                                                                 DebugPrint("Æ 'mntr': ExtractAll_MFT_Luts failed - continuing with TRC...\n");
    01913 #endif
    01914                                                         err = ExtractAll_TRC_Luts( theLutData, theCombiData );
    01915                                                 }
    01916                                         }
    01917                                         break;
    01918                                 case icSigCmykData:
    01919                                 default:                                                                                                                                                                /* this covers: cmCMYK, cmHSVData, cmHLSData, cmCMYData */
    01920                                         err = ExtractAll_MFT_Luts(theLutData, theCombiData, theTag);
    01921                                         break;
    01922                         }
    01923                         break;
    01924                 /* ---------------------------------------------------------------------------------
    01925                         output profile
    01926                    ---------------------------------------------------------------------------------*/
    01927                 case icSigOutputClass:
    01928                         switch (theCombiData->dataColorSpace)
    01929                         {
    01930                                 case icSigGrayData:                                                                                                                                             /*  Gray output Profile */
    01931                                         err = Extract_Gray_Luts( theLutData, theCombiData );
    01932                                         break;
    01933                                 case icSigRgbData:                                                                                                                                                      /*  RGB output Profile */
    01934                                 case icSigCmykData:                                                                                                                                             /*  CMYK output Profile */
    01935                                 default:                                                                                                                                                                /*  this covers also: cmHSVData, cmHLSData, cmCMYData*/
    01936                                         err = ExtractAll_MFT_Luts( theLutData, theCombiData, theTag );
    01937                                         break;
    01938                         }
    01939                         break;
    01940                 /* ---------------------------------------------------------------------------------
    01941                         DeviceLink profile
    01942                    ---------------------------------------------------------------------------------*/
    01943                 case icSigLinkClass:
    01944                         err = ExtractAll_MFT_Luts( theLutData, theCombiData, icSigAToB0Tag );
    01945                         break;
    01946                 /* ---------------------------------------------------------------------------------
    01947                         ColorSpaceConversion profile
    01948                    ---------------------------------------------------------------------------------*/
    01949         case icSigColorSpaceClass:              /* 'spac' */
    01950                         if (theCombiData->amIPCS)
    01951                                 err = ExtractAll_MFT_Luts( theLutData, theCombiData, icSigBToA0Tag );
    01952                         else
    01953                                 err = ExtractAll_MFT_Luts( theLutData, theCombiData, icSigAToB0Tag );
    01954                         break;
    01955                 /* ---------------------------------------------------------------------------------
    01956                         Abstract profile
    01957                    ---------------------------------------------------------------------------------*/
    01958         case icSigAbstractClass:                /* 'abst' */
    01959                         err = ExtractAll_MFT_Luts( theLutData, theCombiData, icSigAToB0Tag );
    01960                         break;
    01961                 default:
    01962                         err = cmProfileError;
    01963                         break;
    01964         }
    01965
    01966         LH_END_PROC("ExtractAllLuts")
    01967         return err;
    01968 }

CMError FillLuts | ( | CMMModelHandle | CMSession,
|  | CMProfileRef | srcProfile,
|  | CMProfileRef | dstProfile
| ) |

CMError GetMatrixFromProfile | ( | CMLutParamPtr | theLutData,
|  | LHCombiDataPtr | theCombiData,
|  | OSType | theTag,
|  | double | factor
| ) |

Definition at line 454 of file lh_core/genluts.c.

References BlockMoveData, CMError, CMGetPartialProfileElement(), Fixed, LH_END_PROC, LH_START_PROC, Matrix2D, CMLutParam::matrixMFT, nil, noErr, OSErr, SINT32, SmartNewPtr(), LHCombiData::theProfile, and UINT32.

Referenced by ExtractAll_MFT_Luts(), and MakeSessionFromLink().

    00458 {
    00459         CMError         err = noErr;
    00460         OSErr           aOSerr = noErr;
    00461         SINT32          i;
    00462         SINT32          j;
    00463         Matrix2D        localMatrix;
    00464         long            matrix[3][3];
    00465         UINT32          byteCount;
    00466         SINT32          offset;
    00467
    00468         LH_START_PROC("GetMatrixFromProfile")
    00469
    00470         /* -------------------------------------------------------- get tag data from profile */
    00471         offset    = 12; /* matrix starts at byte 12 */
    00472         byteCount = 9 * sizeof(Fixed);
    00473         err = CMGetPartialProfileElement(theCombiData->theProfile, theTag, offset, &byteCount, &matrix);
    00474 #ifdef IntelMode
    00475         SwapLongOffset( &matrix, 0, byteCount );
    00476 #endif
    00477         if (err)
    00478                 goto CleanupAndExit;
    00479
    00480         for (i = 0; i < 3; i++)
    00481                 for (j = 0; j < 3; j++)
    00482                         localMatrix[i][j] =  (double)( matrix[i][j] / 65536.0 * factor);
    00483
    00484         if ( 0  || localMatrix[0][0] + localMatrix[1][1] + localMatrix[2][2] != 3.0 )           /* ignore ident */
    00485         {
    00486                 theLutData->matrixMFT = SmartNewPtr(sizeof(Matrix2D), &aOSerr);
    00487                 err = aOSerr;
    00488                 if (err)
    00489                         goto CleanupAndExit;
    00490                 BlockMoveData(localMatrix, theLutData->matrixMFT, sizeof(Matrix2D));
    00491         }
    00492         else
    00493                 theLutData->matrixMFT = nil;
    00494         /* ---------------------------------------------------------------------------------
    00495             clean up
    00496            ---------------------------------------------------------------------------------*/
    00497 CleanupAndExit:
    00498
    00499         LH_END_PROC("GetMatrixFromProfile")
    00500         return err;
    00501 }

CMError PrepareCombiLUTs | ( | CMMModelPtr | CMSession,
|  | CMConcatProfileSet * | profileSet
| ) |

Definition at line 3432 of file lh_core/genluts.c.

References Boolean, cmBestMode, CMError, CMGetProfileHeader(), CMLutParam::colorLut, CMLutParam::colorLutGridPoints, CMLutParam::colorLutInDim, CMLutParam::colorLutOutDim, CMLutParam::colorLutWordSize, icHeader::colorSpace, LHConcatProfileSet::count, CMConcatProfileSet::count, Create_LH_ProfileSet(), CreateCombi(), DATA_2_PTR, DebugPrint, icHeader::deviceClass, DISPOSE_IF_DATA, DisposeIfPtr(), dwFlags, FALSE, icHeader::flags, icSigDisplayClass, icSigLinkClass, icSigOutputClass, icSigRgbData, icSigXYZData, CMLutParam::inputLut, CMLutParam::inputLutEntryCount, CMLutParam::inputLutWordSize, kCMMNewLinkProfile, kCreateGamutLutMask, kDoDefaultLut, kDoGamutLut, kDoLab2XYZ, LH_END_PROC, LH_START_PROC, LOCK_DATA, NamedColorProfileAtEnd, NamedColorProfileOnly, nil, noErr, CMLutParam::outputLut, CMLutParam::outputLutEntryCount, CMLutParam::outputLutWordSize, icHeader::pcs, LHProfile::pcsConversionMode, LHConcatProfileSet::prof, LHProfile::profileSet, CMConcatProfileSet::profileSet, Ptr, LHProfile::renderingIntent, SetMem(), TRUE, UINT16, and UNLOCK_DATA.

Referenced by CMMConcatInitPrivate(), and CMMInitPrivate().

    03434 {
    03435         icHeader                         firstHeader;
    03436         icHeader                         lastHeader;
    03437         LHConcatProfileSet*      newProfileSet = nil;
    03438         CMError                          err = noErr;
    03439         Boolean                          needGamutCalc  = FALSE;
    03440         CMLutParam                       theLutData;
    03441         UINT16                           count;
    03442
    03443         LH_START_PROC("PrepareCombiLUTs")
    03444         /*err = PrepareCombiLUTsNew     ( CMSession, profileSet );
    03445         LH_END_PROC("PrepareCombiLUTs")
    03446         return err;*/
    03447         SetMem(&theLutData, sizeof(CMLutParam), 0);
    03448         count = profileSet->count;
    03449
    03450         /* ------------------------------------------------------------------------------------------------*/
    03451         err = CMGetProfileHeader(profileSet->profileSet[0], (CMCoreProfileHeader *)&firstHeader);
    03452         if (err)
    03453                 goto CleanupAndExit;
    03454         (CMSession)->firstColorSpace = firstHeader.colorSpace;
    03455
    03456         err = CMGetProfileHeader(profileSet->profileSet[count-1], (CMCoreProfileHeader *)&lastHeader);
    03457         if (err)
    03458                 goto CleanupAndExit;
    03459         (CMSession)->lastColorSpace = lastHeader.colorSpace;
    03460         if( lastHeader.deviceClass == icSigLinkClass )
    03461                 (CMSession)->lastColorSpace = lastHeader.pcs;
    03462         else
    03463                 (CMSession)->lastColorSpace = lastHeader.colorSpace;
    03464 #ifdef ALLOW_DEVICE_LINK
    03465         if( count > 1 && lastHeader.deviceClass == icSigLinkClass ){
    03466                 (CMSession)->appendDeviceLink = TRUE;
    03467                 profileSet->count--;
    03468         }
    03469         else{
    03470                 (CMSession)->appendDeviceLink = FALSE;
    03471         }
    03472 #endif
    03473         /* ------------------------------------------------------------------------------------------------
    03474                 right now we create the gamut-luts always if the last profile is a display -or- an output profile
    03475                 (NO gamut-luts are created for a CMMNewLinkProfile-call).
    03476            ------------------------------------------------------------------------------------------------*/
    03477         if  ( (lastHeader.deviceClass == icSigOutputClass) ||  (lastHeader.deviceClass == icSigDisplayClass) )
    03478                 needGamutCalc = TRUE;
    03479
    03480         if ( (CMSession)->currentCall == kCMMNewLinkProfile )
    03481                 needGamutCalc = FALSE;
    03482
    03483         /* ------------------------------------------------------------------------------------------------
    03484                 we could speed up the init-phase if we would use a flag in the first profile to indicate whether
    03485                 or not the gamut-luts should be created:
    03486            ------------------------------------------------------------------------------------------------*/
    03487         if ( (firstHeader.flags & kCreateGamutLutMask) == kCreateGamutLutMask)
    03488                 needGamutCalc = FALSE;
    03489
    03490 #ifdef RenderInt
    03491         if( CMSession-> dwFlags != 0xffffffff ){
    03492                 if( CMSession->dwFlags & kCreateGamutLutMask ){
    03493                         needGamutCalc = FALSE;
    03494                 }
    03495                 else if( lastHeader.deviceClass == icSigOutputClass ||
    03496                                  lastHeader.deviceClass == icSigDisplayClass )
    03497                         needGamutCalc = TRUE;
    03498         }
    03499 #endif
    03500         /* ------------------------------------------------------------------------------------------------*/
    03501         err = Create_LH_ProfileSet( CMSession, profileSet, &newProfileSet);
    03502         if (err)
    03503                 goto CleanupAndExit;
    03504
    03505 #ifdef DEBUG_OUTPUT
    03506         if ( ! needGamutCalc && DebugCheck(kThisFile, kDebugMiscInfo) )
    03507         DebugPrint("\n  <=================== Gamut Combi is not created =================>\n\n");
    03508 #endif
    03509     /*=============================================================================================*/
    03510     /* Create Gamut Combi*/
    03511     /*=============================================================================================*/
    03512         if( CMSession->hasNamedColorProf == NamedColorProfileOnly ||
    03513                 CMSession->hasNamedColorProf == NamedColorProfileAtEnd )needGamutCalc = FALSE;
    03514     if (needGamutCalc)
    03515     {
    03516 #ifdef DEBUG_OUTPUT
    03517         if ( DebugCheck(kThisFile, kDebugMiscInfo) )
    03518             DebugPrint("  <======================= Create Gamut Combi =====================>\n");
    03519 #endif
    03520                 if( lastHeader.pcs != icSigXYZData &&                   /* since there's only a makeGamutForMonitor for xyz */
    03521                         lastHeader.deviceClass == icSigDisplayClass &&
    03522                         lastHeader.colorSpace == icSigRgbData ){        /* insert a Lab->XYZ conversion */
    03523
    03524                         newProfileSet->prof[newProfileSet->count] = newProfileSet->prof[newProfileSet->count-1];
    03525                         newProfileSet->prof[newProfileSet->count-1].pcsConversionMode = kDoLab2XYZ;             /* create Lab->XYZ */
    03526                         newProfileSet->prof[newProfileSet->count-1].profileSet = 0;
    03527                         newProfileSet->prof[newProfileSet->count-1].renderingIntent = 0;
    03528                         newProfileSet->count++;
    03529                 }
    03530                 err = CreateCombi(CMSession, profileSet, newProfileSet, &theLutData, kDoGamutLut );
    03531                 if( lastHeader.pcs != icSigXYZData &&                   /* since there's only a makeGamutForMonitor for xyz */
    03532                         lastHeader.deviceClass == icSigDisplayClass &&
    03533                         lastHeader.colorSpace == icSigRgbData ){                        /* remove a Lab->XYZ conversion */
    03534
    03535                         newProfileSet->count--;
    03536                         newProfileSet->prof[newProfileSet->count-1] = newProfileSet->prof[newProfileSet->count];
    03537                 }
    03538                 /* continue even if err != noErr !!!!*/
    03539 #ifdef DEBUG_OUTPUT
    03540                 if ( err && DebugCheck(kThisFile, kDebugErrorInfo) )
    03541                         DebugPrint("¥ Error: PrepareCombiLUTs - kDoGamutLut: %d\n",err);
    03542 #endif
    03543
    03544                 if (err == noErr)
    03545                 {
    03546 #ifdef DEBUG_OUTPUT
    03547                         if (DebugLutCheck(kDisplayEXAGamut) )
    03548                         {
    03549                                 LOCK_DATA(theLutData.inputLut);
    03550                                 LOCK_DATA(theLutData.colorLut);
    03551                                 LOCK_DATA(theLutData.outputLut);
    03552                                 DoDisplayLutNew("\pFINAL GAMUT E Lut", &theLutData, 0);
    03553                                 DoDisplayLutNew("\pFINAL GAMUT A Lut", &theLutData, 2);
    03554                                 DoDisplayLutNew("\pFINAL GAMUT X Lut", &theLutData, 1);
    03555                                 UNLOCK_DATA(theLutData.inputLut);
    03556                                 UNLOCK_DATA(theLutData.colorLut);
    03557                                 UNLOCK_DATA(theLutData.outputLut);
    03558                         }
    03559                         if ( DebugLutCheck( kDisplayGamut ) )
    03560                         {
    03561                                 LOCK_DATA(theLutData.colorLut);
    03562                                 if ((CMSession)->precision == cmBestMode)
    03563                                         Show32by32by32GamutXLUT(DATA_2_PTR(theLutData.colorLut));
    03564                                 else
    03565                                         Show16by16by16GamutXLUT(DATA_2_PTR(theLutData.colorLut));
    03566                                 UNLOCK_DATA(theLutData.colorLut);
    03567                         }
    03568 #endif
    03569                         if (theLutData.inputLut == nil)
    03570                         {
    03571 #ifdef DEBUG_OUTPUT
    03572                                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    03573                                         DebugPrint("¥ ERROR: final Gamut Elut == nil\n");
    03574 #endif
    03575                         } else
    03576                         {
    03577                                 (CMSession)->gamutLutParam.inputLut = theLutData.inputLut;                                                                                              /* E lut */
    03578                                 theLutData.inputLut = nil;
    03579                         }
    03580
    03581                         if (theLutData.outputLut == nil)
    03582                         {
    03583 #ifdef DEBUG_OUTPUT
    03584                                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    03585                                         DebugPrint("¥ ERROR: final Gamut Alut == nil\n");
    03586 #endif
    03587                         } else
    03588                         {
    03589                                 (CMSession)->gamutLutParam.outputLut = theLutData.outputLut;                                                                                    /* A lut */
    03590                                 theLutData.outputLut = nil;
    03591                         }
    03592
    03593                         if (theLutData.colorLut == nil)
    03594                         {
    03595 #ifdef DEBUG_OUTPUT
    03596                                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    03597                                         DebugPrint("¥ ERROR: final Gamut Xlut == nil\n");
    03598 #endif
    03599                         } else
    03600                         {
    03601                                 (CMSession)->gamutLutParam.colorLut = theLutData.colorLut;                                                                                              /* X lut */
    03602                                 theLutData.colorLut = nil;
    03603                         }
    03604                         (CMSession)->gamutLutParam.colorLutInDim                = theLutData.colorLutInDim;
    03605                         (CMSession)->gamutLutParam.colorLutOutDim               = theLutData.colorLutOutDim;
    03606                         (CMSession)->gamutLutParam.colorLutGridPoints   = theLutData.colorLutGridPoints;
    03607                         (CMSession)->gamutLutParam.colorLutWordSize             = theLutData.colorLutWordSize;
    03608                         (CMSession)->gamutLutParam.inputLutWordSize             = theLutData.inputLutWordSize;
    03609                         (CMSession)->gamutLutParam.outputLutWordSize    = theLutData.outputLutWordSize;
    03610                         (CMSession)->gamutLutParam.inputLutEntryCount   = theLutData.inputLutEntryCount;
    03611                         (CMSession)->gamutLutParam.outputLutEntryCount  = theLutData.outputLutEntryCount;
    03612                 }
    03613                 else{
    03614                         theLutData.inputLut             = DISPOSE_IF_DATA(theLutData.inputLut);
    03615                         theLutData.outputLut    = DISPOSE_IF_DATA(theLutData.outputLut);
    03616                         theLutData.colorLut             = DISPOSE_IF_DATA(theLutData.colorLut);
    03617                 }
    03618         }
    03619         /*=============================================================================================
    03620            Create 'real' Combi
    03621           =============================================================================================*/
    03622 #ifdef DEBUG_OUTPUT
    03623         if ( DebugCheck(kThisFile, kDebugMiscInfo) )
    03624                 DebugPrint("  <======================= Create real Combi ======================>\n");
    03625 #endif
    03626
    03627         err = CreateCombi(CMSession, profileSet, newProfileSet, &theLutData, kDoDefaultLut );
    03628         if (err){
    03629                 CMSession->theNamedColorTagData         = DISPOSE_IF_DATA( CMSession->theNamedColorTagData);
    03630                 CMSession->gamutLutParam.inputLut       = DISPOSE_IF_DATA( CMSession->gamutLutParam.inputLut);
    03631                 CMSession->gamutLutParam.outputLut      = DISPOSE_IF_DATA( CMSession->gamutLutParam.outputLut);
    03632                 CMSession->gamutLutParam.colorLut       = DISPOSE_IF_DATA( CMSession->gamutLutParam.colorLut);
    03633                 goto CleanupAndExit;
    03634         }
    03635
    03636 #ifdef DEBUG_OUTPUT
    03637         if (DebugLutCheck(kDebugEXAReal) )
    03638         {
    03639                 LOCK_DATA(theLutData.inputLut);
    03640                 LOCK_DATA(theLutData.colorLut);
    03641                 LOCK_DATA(theLutData.outputLut);
    03642                 DoDisplayLutNew("\pFINAL E Lut", &theLutData, 0);
    03643                 DoDisplayLutNew("\pFINAL A Lut", &theLutData, 2);
    03644                 DoDisplayLutNew("\pFINAL X Lut", &theLutData, 1);
    03645                 UNLOCK_DATA(theLutData.inputLut);
    03646                 UNLOCK_DATA(theLutData.colorLut);
    03647                 UNLOCK_DATA(theLutData.outputLut);
    03648         }
    03649 #endif
    03650 #ifdef WRITE_LUTS
    03651         LOCK_DATA(theLutData.inputLut);
    03652         LOCK_DATA(theLutData.colorLut);
    03653         LOCK_DATA(theLutData.outputLut);
    03654         WriteLut2File( "\pFINAL E Lut",theLutData.inputLut, 'ELUT');
    03655         WriteLut2File( "\pFINAL A Lut",theLutData.outputLut, 'ALUT');
    03656         WriteLut2File( "\pFINAL X Lut",theLutData.colorLut, 'XLUT');
    03657         UNLOCK_DATA(theLutData.inputLut);
    03658         UNLOCK_DATA(theLutData.colorLut);
    03659         UNLOCK_DATA(theLutData.outputLut);
    03660 #endif
    03661         /*------------------------ save all results...*/
    03662         if (theLutData.inputLut == nil)
    03663         {
    03664 #ifdef DEBUG_OUTPUT
    03665                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    03666                         DebugPrint("¥ ERROR: theLutData.inputLut == nil\n");
    03667 #endif
    03668         } else
    03669         {
    03670                 (CMSession)->lutParam.inputLut = theLutData.inputLut;                                                                                           /* E lut */
    03671                 theLutData.inputLut = nil;
    03672         }
    03673
    03674         if (theLutData.outputLut == nil)
    03675         {
    03676 #ifdef DEBUG_OUTPUT
    03677                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    03678                         DebugPrint("¥ ERROR: theLutData.outputLut == nil\n");
    03679 #endif
    03680         } else
    03681         {
    03682                 (CMSession)->lutParam.outputLut = theLutData.outputLut;                                                                                 /* A lut */
    03683                 theLutData.outputLut = nil;
    03684         }
    03685
    03686         if (theLutData.colorLut == nil)
    03687         {
    03688 #ifdef DEBUG_OUTPUT
    03689                 if ( DebugCheck(kThisFile, kDebugErrorInfo) )
    03690                         DebugPrint("¥ ERROR: theLutData.colorLut == nil\n");
    03691 #endif
    03692         } else
    03693         {
    03694                 (CMSession)->lutParam.colorLut = theLutData.colorLut;                                                                                           /* X lut */
    03695                 theLutData.colorLut = nil;
    03696         }
    03697
    03698         (CMSession)->lutParam.colorLutInDim                     = theLutData.colorLutInDim;
    03699         (CMSession)->lutParam.colorLutOutDim            = theLutData.colorLutOutDim;
    03700         (CMSession)->lutParam.colorLutGridPoints        = theLutData.colorLutGridPoints;
    03701         (CMSession)->lutParam.colorLutWordSize          = theLutData.colorLutWordSize;
    03702         (CMSession)->lutParam.inputLutWordSize          = theLutData.inputLutWordSize;
    03703         (CMSession)->lutParam.outputLutWordSize         = theLutData.outputLutWordSize;
    03704         (CMSession)->lutParam.inputLutEntryCount        = theLutData.inputLutEntryCount;
    03705         (CMSession)->lutParam.outputLutEntryCount       = theLutData.outputLutEntryCount;
    03706
    03707         /* ---------------------------------------------------------------------------------
    03708             clean up & exit
    03709            ---------------------------------------------------------------------------------*/
    03710 CleanupAndExit:
    03711         newProfileSet = (LHConcatProfileSet *)DisposeIfPtr((Ptr)newProfileSet);
    03712         theLutData.inputLut             = DISPOSE_IF_DATA(theLutData.inputLut);
    03713         theLutData.outputLut    = DISPOSE_IF_DATA(theLutData.outputLut);
    03714         theLutData.colorLut             = DISPOSE_IF_DATA(theLutData.colorLut);
    03715
    03716         LH_END_PROC("PrepareCombiLUTs")
    03717         return err;
    03718 }