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

pi_cmm.c File Reference

#include "General.h"
#include "GenLuts.h"
#include "PI_CMM.h"
#include "StdConv.h"

Go to the source code of this file.

Defines

#define ALLOW_DEVICE_LINK   /* allows link as the last profile in a chain, change in genluts.c too */

Functions

CMError CMMInitPrivate (CMMModelPtr storage, CMProfileRef srcProfile, CMProfileRef dstProfile)
CMError MakeSessionFromLink (CMMModelPtr storage, CMConcatProfileSet *profileSet)
CMError CMMConcatInitPrivate (CMMModelPtr storage, CMConcatProfileSet *profileSet)
Boolean IsPowerOf2 (unsigned long l)


Define Documentation

#define ALLOW_DEVICE_LINK   /* allows link as the last profile in a chain, change in genluts.c too */
 

Definition at line 39 of file w98/lh_open/pi_cmm.c.


Function Documentation

CMError CMMConcatInitPrivate CMMModelPtr  storage,
CMConcatProfileSet profileSet
 

Definition at line 197 of file w98/lh_open/pi_cmm.c.

References Boolean, cmCantConcatenateError, CMError, CMGetProfileHeader(), cmparamErr, cmProfileError, CMProfileRef, CMValidateProfile(), CMConcatProfileSet::count, DebugPrint, icHeader::deviceClass, DISPOSE_IF_DATA, dwFlags, icHeader::flags, icSigAbstractClass, icSigLinkClass, icSigNamedColorClass, CMConcatProfileSet::keyIndex, kLookupOnlyMask, MakeSessionFromLink(), noErr, PrepareCombiLUTs(), CMConcatProfileSet::profileSet, and TickCount().

Referenced by CWConcatColorWorld(), CWConcatColorWorld4MS(), and CWLinkColorWorld().

00199 { 00200 CMCoreProfileHeader firstHeader; 00201 CMCoreProfileHeader lastHeader; 00202 CMCoreProfileHeader tempHeader; 00203 CMError err = noErr; 00204 unsigned short count; 00205 unsigned short loop; 00206 Boolean valid; 00207 CMProfileRef theProfile; 00208 #ifdef DEBUG_OUTPUT 00209 long timer = TickCount(); 00210 #endif 00211 00212 00213 #ifdef DEBUG_OUTPUT 00214 if ( DebugCheck(kThisFile, kDebugMiscInfo) ) 00215 { 00216 DebugPrint("� ->CMMConcatInitPrivate\n"); 00217 DebugPrint(" got %d profiles keyindex is %d \n", profileSet->count, profileSet->keyIndex); 00218 } 00219 #endif 00220 00221 count = profileSet->count; 00222 if (count == 0) 00223 { 00224 err = cmparamErr; 00225 goto CleanupAndExit; 00226 } 00227 /* ------------------------------------------------------------------------------------------ get first header */ 00228 err = CMGetProfileHeader( profileSet->profileSet[0], &firstHeader); 00229 if (err) 00230 goto CleanupAndExit; 00231 /* ------------------------------------------------------------------------------------------ only one profile? -> has to be a link profile */ 00232 storage->lookup = (Boolean)((firstHeader.flags & kLookupOnlyMask)>>16); /* lookup vs. interpolation */ 00233 00234 #ifdef RenderInt 00235 if( storage-> dwFlags != 0xffffffff ){ 00236 storage->lookup = (Boolean)((storage-> dwFlags & kLookupOnlyMask)>>16); 00237 } 00238 #endif 00239 if (count == 1 && firstHeader.deviceClass != icSigNamedColorClass ) 00240 { 00241 if (firstHeader.deviceClass != icSigLinkClass && firstHeader.deviceClass != icSigAbstractClass ) 00242 { 00243 err =cmCantConcatenateError; 00244 goto CleanupAndExit; 00245 } 00246 else{ 00247 err = MakeSessionFromLink( storage, profileSet ); 00248 if( err == 0 )return noErr; 00249 } 00250 lastHeader = firstHeader; 00251 } else 00252 { 00253 /* -------------------------------------------------------------------------------------- get last header */ 00254 err = CMGetProfileHeader( profileSet->profileSet[count-1], &lastHeader); 00255 if (err) 00256 goto CleanupAndExit; 00257 #ifndef ALLOW_DEVICE_LINK 00258 if (lastHeader.deviceClass == icSigLinkClass) 00259 { 00260 err = cmCantConcatenateError; 00261 goto CleanupAndExit; 00262 } 00263 #endif 00264 } 00265 00266 /* ------------------------------------------------------------------------------------------ valid profiles ??? */ 00267 for ( loop = 0; loop < count; loop++) 00268 { 00269 theProfile = profileSet->profileSet[loop]; 00270 err = CMValidateProfile( theProfile, &valid ); 00271 if (err) 00272 goto CleanupAndExit; 00273 if (!valid) 00274 { 00275 #ifdef DEBUG_OUTPUT 00276 if ( DebugCheck(kThisFile, kDebugErrorInfo) ) 00277 DebugPrint("� CMMConcatInitPrivate ERROR: profile #%d is NOT valid!\n", loop); 00278 #endif 00279 #ifdef realThing 00280 err = cmProfileError; 00281 goto CleanupAndExit; 00282 #endif 00283 } 00284 /* -------------------------------------------------------------------------------------- link profiles may not be used inbetween */ 00285 if ( (loop > 0) && (loop < count-1)) 00286 { 00287 err = CMGetProfileHeader( profileSet->profileSet[loop], &tempHeader); 00288 if (err) 00289 goto CleanupAndExit; 00290 if (tempHeader.deviceClass == icSigLinkClass) 00291 { 00292 err = cmCantConcatenateError; 00293 goto CleanupAndExit; 00294 } 00295 } 00296 } 00297 00298 /* ------------------------------------------------------------------------------------------ no abstract profile as first or last */ 00299 if ( (count >1) && ( (firstHeader.deviceClass == icSigAbstractClass) || (lastHeader.deviceClass == icSigAbstractClass) ) ) 00300 { 00301 err = cmCantConcatenateError; 00302 goto CleanupAndExit; 00303 } 00304 00305 /* ------------------------------------------------------------------------------------------ initialization */ 00306 (storage)->lutParam.inputLut = DISPOSE_IF_DATA((storage)->lutParam.inputLut); 00307 (storage)->lutParam.colorLut = DISPOSE_IF_DATA((storage)->lutParam.colorLut); 00308 (storage)->lutParam.outputLut = DISPOSE_IF_DATA((storage)->lutParam.outputLut); 00309 00310 (storage)->gamutLutParam.inputLut = DISPOSE_IF_DATA((storage)->gamutLutParam.inputLut); 00311 (storage)->gamutLutParam.colorLut = DISPOSE_IF_DATA((storage)->gamutLutParam.colorLut); 00312 (storage)->gamutLutParam.outputLut = DISPOSE_IF_DATA((storage)->gamutLutParam.outputLut); 00313 00314 (storage)->theNamedColorTagData = DISPOSE_IF_DATA((storage)->theNamedColorTagData); 00315 /* ------------------------------------------------------------------------------------------ check 'special' cases */ 00316 { 00317 err = PrepareCombiLUTs( storage, profileSet ); 00318 } 00319 00320 CleanupAndExit: 00321 00322 #ifdef DEBUG_OUTPUT 00323 if ( err && DebugCheck(kThisFile, kDebugErrorInfo) ) 00324 DebugPrint(" CMMConcatInitPrivate: err = %d\n", err); 00325 DebugPrint(" time in CMMConcatInitPrivate: %f second(s)\n",(TickCount()-timer)/60.0); 00326 DebugPrint("� <-CMMConcatInitPrivate\n"); 00327 #endif 00328 return( err ); 00329 }

CMError CMMInitPrivate CMMModelPtr  storage,
CMProfileRef  srcProfile,
CMProfileRef  dstProfile
 

Definition at line 60 of file w98/lh_open/pi_cmm.c.

References Boolean, cmCantConcatenateError, CMConcatProfileSet, CMError, CMGetProfileHeader(), cmProfileError, CMProfileRef, CMValidateProfile(), CMConcatProfileSet::count, DebugPrint, icHeader::deviceClass, DISPOSE_IF_DATA, DisposeIfPtr(), dwFlags, icHeader::flags, icSigLinkClass, icVersionNumber, CMConcatProfileSet::keyIndex, kLookupOnlyMask, nil, noErr, OSErr, PrepareCombiLUTs(), CMConcatProfileSet::profileSet, Ptr, SmartNewPtr(), TickCount(), and icHeader::version.

Referenced by CWNewColorWorld().

00063 { 00064 CMError err = noErr; 00065 OSErr aOSerr = noErr; 00066 CMConcatProfileSet *profileSet = nil; 00067 CMCoreProfileHeader sourceHeader; 00068 CMCoreProfileHeader destHeader; 00069 Boolean valid; 00070 short mode = 0; 00071 #ifdef DEBUG_OUTPUT 00072 long timer = TickCount(); 00073 #endif 00074 00075 #ifdef DEBUG_OUTPUT 00076 if ( DebugCheck(kThisFile, kDebugMiscInfo) ) 00077 DebugPrint("� ->CMMInitPrivate\n"); 00078 #endif 00079 00080 /* --------------------------------------------------------------------------------------- valid profiles ???*/ 00081 err = CMValidateProfile( srcProfile, &valid ); 00082 if (err) 00083 goto CleanupAndExit; 00084 if (!valid) 00085 { 00086 #ifdef DEBUG_OUTPUT 00087 if ( DebugCheck(kThisFile, kDebugErrorInfo) ) 00088 DebugPrint("� CMMInitPrivate ERROR: srcProfile is NOT valid!\n"); 00089 #endif 00090 00091 #ifdef realThing 00092 err = cmProfileError; 00093 goto CleanupAndExit; 00094 #endif 00095 } 00096 00097 err = CMValidateProfile(dstProfile, &valid ); 00098 if (err) 00099 goto CleanupAndExit; 00100 if (!valid) 00101 { 00102 #ifdef DEBUG_OUTPUT 00103 if ( DebugCheck(kThisFile, kDebugErrorInfo) ) 00104 DebugPrint("� CMMInitPrivate ERROR: dstProfile is NOT valid!\n"); 00105 #endif 00106 #ifdef realThing 00107 err = cmProfileError; 00108 goto CleanupAndExit; 00109 #endif 00110 } 00111 00112 /* --------------------------------------------------------------------------------------- initialization*/ 00113 (storage)->lutParam.inputLut = DISPOSE_IF_DATA((storage)->lutParam.inputLut); 00114 (storage)->lutParam.colorLut = DISPOSE_IF_DATA((storage)->lutParam.colorLut); 00115 (storage)->lutParam.outputLut = DISPOSE_IF_DATA((storage)->lutParam.outputLut); 00116 00117 (storage)->gamutLutParam.inputLut = DISPOSE_IF_DATA((storage)->gamutLutParam.inputLut); 00118 (storage)->gamutLutParam.colorLut = DISPOSE_IF_DATA((storage)->gamutLutParam.colorLut); 00119 (storage)->gamutLutParam.outputLut = DISPOSE_IF_DATA((storage)->gamutLutParam.outputLut); 00120 00121 (storage)->theNamedColorTagData = DISPOSE_IF_DATA((storage)->theNamedColorTagData); 00122 00123 (storage)->srcProfileVersion = icVersionNumber; 00124 (storage)->dstProfileVersion = icVersionNumber; 00125 00126 /* --------------------------------------------------------------------------------------- check version of source profile*/ 00127 err = CMGetProfileHeader( srcProfile, &sourceHeader); 00128 if (err) 00129 goto CleanupAndExit; 00130 00131 if ( !((sourceHeader.version & 0xff000000) >= icVersionNumber) ){ 00132 err = cmProfileError; 00133 goto CleanupAndExit; 00134 } 00135 if (sourceHeader.deviceClass == icSigLinkClass) 00136 { 00137 err = cmCantConcatenateError; 00138 goto CleanupAndExit; 00139 } 00140 00141 /* --------------------------------------------------------------------------------------- check version of destination profile*/ 00142 err = CMGetProfileHeader( dstProfile, &destHeader); 00143 if (err) 00144 goto CleanupAndExit; 00145 00146 if ( !((destHeader.version & 0xff000000) >= icVersionNumber) ){ 00147 err = cmProfileError; 00148 goto CleanupAndExit; 00149 } 00150 if (destHeader.deviceClass == icSigLinkClass) 00151 { 00152 err = cmCantConcatenateError; 00153 goto CleanupAndExit; 00154 } 00155 storage->lookup = (Boolean)((sourceHeader.flags & kLookupOnlyMask)>>16); /* lookup vs. interpolation */ 00156 00157 #ifdef RenderInt 00158 if( storage-> dwFlags != 0xffffffff ){ 00159 storage->lookup = (Boolean)((storage-> dwFlags & kLookupOnlyMask)>>16); 00160 } 00161 #endif 00162 /* --------------------------------------------------------------------------------------- 'normal' cases*/ 00163 profileSet = (CMConcatProfileSet *)SmartNewPtr(sizeof (CMConcatProfileSet) + sizeof(CMProfileRef), &aOSerr); 00164 if (aOSerr) 00165 goto CleanupAndExit; 00166 00167 profileSet->count = 2; 00168 profileSet->keyIndex = 1; 00169 /* profileSet->flags = sourceHeader.flags; */ 00170 profileSet->profileSet[0] = srcProfile; 00171 /* profileSet->profileSet[0]->renderingIntent = sourceHeader.renderingIntent; */ 00172 profileSet->profileSet[1] = dstProfile; 00173 /* profileSet->profileSet[1]->renderingIntent = destHeader.renderingIntent; */ 00174 00175 err = PrepareCombiLUTs( storage, profileSet ); 00176 if (err) 00177 goto CleanupAndExit; 00178 00179 CleanupAndExit: 00180 profileSet = (CMConcatProfileSet*)DisposeIfPtr( (Ptr)profileSet ); 00181 00182 #ifdef DEBUG_OUTPUT 00183 if ( err && DebugCheck(kThisFile, kDebugErrorInfo) ) 00184 DebugPrint("� CMMInitPrivate: err = %d\n", err); 00185 if ( DebugCheck(kThisFile, kDebugTimingInfo) ) 00186 DebugPrint(" time in CMMInitPrivate: %f second(s)\n",(TickCount()-timer)/60.0); 00187 if ( DebugCheck(kThisFile, kDebugMiscInfo) ) 00188 DebugPrint("� <-CMMInitPrivate\n"); 00189 #endif 00190 return err; 00191 }

Boolean IsPowerOf2 unsigned long  l  ) 
 

CMError MakeSessionFromLink CMMModelPtr  storage,
CMConcatProfileSet profileSet
 

Referenced by CMMConcatInitPrivate().


Generated on Sat May 15 19:45:08 2004 for test by doxygen 1.3.7