test: w98/lh_core/routines.h File Reference

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

# routines.h File Reference

Go to the source code of this file.

## Defines

#define | UWE 2

## Functions

OSErr | CalcGridPoints4Cube (long theCubeSize, long inputDim, long *theGridPoints, long *theGridBits)
OSErr | MakeCube (long inputDim, long *thePtrSize, CUBE_DATA_TYPE *theCube, long *theBits)
OSErr | MakeCMColorCube (long inputDim, long *theCubeSize, CUBE_DATA_TYPE *aHdlPtr, long *theBits)
OSErr | MakeCube16 (long inputDim, long *theCubeSize, CUBE_DATA_TYPE *theCube, long *theBits, long *theExtraSize)

## Define Documentation

#define UWE 2

| Definition at line 42 of file w98/lh_core/routines.h.

## Function Documentation

OSErr CalcGridPoints4Cube | ( | long | theCubeSize,
|  | long | inputDim,
|  | long * | theGridPoints,
|  | long * | theGridBits
| ) |

Definition at line 35 of file lh_core/routines.c.

References cmparamErr, LH_END_PROC, LH_START_PROC, noErr, and OSErr.

Referenced by CreateCombi(), MakeCMColorCube(), MakeCube(), MakeCube16(), and MakeSpecialCube16().

    00039 {
    00040         long                    aSize,needBits,theSize;
    00041         register long   loop,gridPoints;
    00042         OSErr                   err = noErr;
    00043
    00044         LH_START_PROC("CalcGridPoints4Cube")
    00045
    00046         if( inputDim > 8 )
    00047         {
    00048                 err = cmparamErr;
    00049                 goto CleanupAndExit;
    00050         }
    00051         aSize = theCubeSize / inputDim;
    00052         needBits=0;
    00053         do
    00054         {
    00055                 needBits++;
    00056                 gridPoints = (1<<needBits);
    00057                 theSize = gridPoints;
    00058                 for( loop=1; loop<inputDim; ++loop)
    00059                         theSize *= gridPoints;
    00060         } while( aSize >= theSize );
    00061         needBits--;
    00062         if( needBits <= 0 )
    00063         {
    00064                 err = cmparamErr;
    00065                 goto CleanupAndExit;
    00066         }
    00067         *theGridBits = needBits;
    00068         *theGridPoints = (1<<needBits);
    00069 CleanupAndExit:
    00070         LH_END_PROC("CalcGridPoints4Cube")
    00071         return err;
    00072 }

OSErr MakeCMColorCube | ( | long | inputDim,
|  | long * | theCubeSize,
|  | CUBE_DATA_TYPE * | aHdlPtr,
|  | long * | theBits
| ) |

Definition at line 312 of file lh_core/routines.c.

References ALLOC_DATA, CalcGridPoints4Cube(), cmparamErr, DATA_2_PTR, DISPOSE_IF_DATA, LH_END_PROC, LH_START_PROC, LOCK_DATA, nil, noErr, OSErr, UINT16, and UNLOCK_DATA.

    00316 {
    00317         long    needBits,theSize;
    00318         long    i,gridPoints;
    00319         OSErr   err = noErr;
    00320         UINT16  *cube = nil;
    00321         register long aMaxVal;
    00322         register long aShift;
    00323         long              aRound;
    00324
    00325         LH_START_PROC("MakeCMColorCube")
    00326
    00327         err = CalcGridPoints4Cube(*theCubeSize, inputDim, &gridPoints, &needBits);
    00328         if (err)
    00329                 goto CleanupAndExit;
    00330
    00331         theSize = gridPoints;
    00332         for( i=1; i<inputDim; ++i)theSize *= gridPoints;
    00333
    00334         if( inputDim > 4 )
    00335         {
    00336                 err = cmparamErr;
    00337                 goto CleanupAndExit;
    00338         }
    00339         *theCubeSize = theSize * inputDim;
    00340         if( inputDim != 4 )
    00341                 *theCubeSize = theSize * 4;
    00342
    00343         *aHdlPtr = ALLOC_DATA(*theCubeSize*2, &err);
    00344         if (err != noErr)
    00345                 goto CleanupAndExit;
    00346
    00347         LOCK_DATA( *aHdlPtr );
    00348         cube = (UINT16 *)DATA_2_PTR( *aHdlPtr );
    00349         aMaxVal = (1<<(30-needBits))-1; /* Normierung auf 0xffff*/
    00350         aMaxVal = aMaxVal / ( gridPoints -1 );
    00351         aShift = 30 - needBits - 16;
    00352         aRound = 0;/*(1<<(aShift-1))-1;*/
    00353         if( inputDim == 1 )
    00354         {
    00355                 for( i=0; i<gridPoints; ++i){
    00356                                         *cube++ = (UINT16)(( aMaxVal * i + aRound) >> aShift);
    00357                                         *cube++ = 0;
    00358                                         *cube++ = 0;
    00359                                         *cube++ = 0;
    00360                 }
    00361         }
    00362         else if( inputDim == 2)
    00363         {
    00364                 register long  j;
    00365                 register UINT16 aI;
    00366                 for( i=0; i<gridPoints; ++i){
    00367                         aI = (UINT16)(( aMaxVal * i + aRound ) >> aShift);
    00368                         for( j=0; j<gridPoints; ++j){
    00369                                         *cube++ = aI;
    00370                                         *cube++ = (UINT16)(( aMaxVal * j + aRound ) >> aShift);
    00371                                         *cube++ = 0;
    00372                                         *cube++ = 0;
    00373                         }
    00374                 }
    00375         }
    00376         else if( inputDim == 3)
    00377         {
    00378                 register long  j,k;
    00379                 register UINT16 aI, aJ;
    00380                 for( i=0; i<gridPoints; ++i){
    00381                         aI = (UINT16)(( aMaxVal * i + aRound ) >> aShift);
    00382                         for( j=0; j<gridPoints; ++j){
    00383                                 aJ = (UINT16)(( aMaxVal * j + aRound ) >> aShift);
    00384                                 for( k=0; k<gridPoints; ++k){
    00385                                         *cube++ = aI;
    00386                                         *cube++ = aJ;
    00387                                         *cube++ = (UINT16)(( aMaxVal * k + aRound ) >> aShift);
    00388                                         *cube++ = 0;
    00389                                 }
    00390                         }
    00391                 }
    00392         }
    00393         else if( inputDim == 4){
    00394                 register long  j,k,l;
    00395                 register UINT16 aI, aJ,aK;
    00396                 for( i=0; i<gridPoints; ++i){
    00397                         aI = (UINT16)(( aMaxVal * i + aRound ) >> aShift);
    00398                         for( j=0; j<gridPoints; ++j){
    00399                                 aJ = (UINT16)(( aMaxVal * j + aRound ) >> aShift);
    00400                                 for( k=0; k<gridPoints; ++k){
    00401                                         aK = (UINT16)(( aMaxVal * k + aRound ) >> aShift);
    00402                                         for( l=0; l<gridPoints; ++l){
    00403                                                 *cube++ = aI;
    00404                                                 *cube++ = aJ;
    00405                                                 *cube++ = aK;
    00406                                                 *cube++ = (UINT16)(( aMaxVal * l + aRound ) >> aShift);
    00407                                         }
    00408                                 }
    00409                         }
    00410                 }
    00411         }
    00412         else
    00413         {
    00414                 *aHdlPtr = DISPOSE_IF_DATA(*aHdlPtr);
    00415                 err = cmparamErr;
    00416                 goto CleanupAndExit;
    00417         }
    00418         UNLOCK_DATA(*aHdlPtr);
    00419         *theBits = needBits;
    00420 CleanupAndExit:
    00421         LH_END_PROC("MakeCMColorCube")
    00422         return err;
    00423 }

OSErr MakeCube | ( | long | inputDim,
|  | long * | thePtrSize,
|  | CUBE_DATA_TYPE * | theCube,
|  | long * | theBits
| ) |

Definition at line 75 of file lh_core/routines.c.

References ALLOC_DATA, CalcGridPoints4Cube(), CUBE_DATA_TYPE, DATA_2_PTR, LH_END_PROC, LH_START_PROC, LOCK_DATA, nil, noErr, OSErr, SetValues(), UINT8, and UNLOCK_DATA.

    00079 {
    00080         long                    needBits,theSize;
    00081         long                    i,gridPoints;
    00082         OSErr                   err = noErr;
    00083         UINT8                   *cube = nil;
    00084         CUBE_DATA_TYPE  tempCube;
    00085         /*
    00086         long DivisionReplace[]={ 0,0,7,255, 6,85, 12,4663, 4,17, 15,33693, 12,4145, 14,16449,
    00087                                                          0, 1, 9,511, 10,1021, 11,2041, 12,4081, 13,8161, 14,16321, 15,32641, 16,65281};
    00088         */
    00089
    00090         LH_START_PROC("MakeCube")
    00091         err = CalcGridPoints4Cube(*theCubeSize, inputDim, &gridPoints, &needBits);
    00092         if (err)
    00093                 goto CleanupAndExit;
    00094
    00095         theSize = gridPoints;
    00096         for( i=1; i<inputDim; ++i)
    00097                 theSize *= gridPoints;
    00098
    00099         *theCubeSize = theSize * inputDim;
    00100         tempCube = ALLOC_DATA(theSize * inputDim, &err);
    00101         if (err != noErr)
    00102                 goto CleanupAndExit;
    00103         LOCK_DATA(tempCube);
    00104         cube = (UINT8*)DATA_2_PTR(tempCube);
    00105
    00106         if( inputDim == 3)
    00107         {
    00108                 register long  aShift;
    00109                 register long  j,k;
    00110                 register UINT8 aI, aJ;
    00111                 aShift = (8 - needBits) ;
    00112                 /*
    00113                 aShift = DivisionReplace[2*needBits] - (8 - needBits) ;
    00114                 if( aShift < 0 ){
    00115                         aFactor = DivisionReplace[2*needBits+1]*(1<<(-aShift));
    00116                         aShift = 0;
    00117                 }
    00118                 else aFactor = DivisionReplace[2*needBits+1];
    00119                 */
    00120                 for( i=0; i<gridPoints; ++i){
    00121                         aI = (UINT8)(i<< aShift);
    00122                         for( j=0; j<gridPoints; ++j){
    00123                                 aJ = (UINT8)(j<< aShift);
    00124                                 for( k=0; k<gridPoints; ++k){
    00125                                         *cube++ = aI;
    00126                                         *cube++ = aJ;
    00127                                         *cube++ =(UINT8)(k<< aShift);
    00128                                 }
    00129                         }
    00130                 }
    00131         }
    00132         else
    00133         {
    00134                 SetValues( 0, inputDim, needBits, &cube );
    00135         }
    00136         *theBits = needBits;
    00137         UNLOCK_DATA(tempCube);
    00138         *theCube = tempCube;
    00139 CleanupAndExit:
    00140         LH_END_PROC("MakeCube")
    00141         return err;
    00142 }

OSErr MakeCube16 | ( | long | inputDim,
|  | long * | theCubeSize,
|  | CUBE_DATA_TYPE * | theCube,
|  | long * | theBits,
|  | long * | theExtraSize
| ) |

Definition at line 147 of file lh_core/routines.c.

References ALLOC_DATA, CalcGridPoints4Cube(), CUBE_DATA_TYPE, DATA_2_PTR, LH_END_PROC, LH_START_PROC, LOCK_DATA, nil, noErr, OSErr, SetValues16(), UINT16, and UNLOCK_DATA.

Referenced by CreateCombi().

    00152 {
    00153         long                    needBits,theSize,aExtraSize;
    00154         long                    i,gridPoints;
    00155         OSErr                   err = noErr;
    00156         UINT16                  *cube = nil;
    00157         CUBE_DATA_TYPE  tempCube;
    00158
    00159         LH_START_PROC("MakeCube16")
    00160         /*
    00161                 long DivisionReplace[]={ 0,0,7,255, 6,85, 12,4663, 4,17, 15,33693, 12,4145, 14,16449,
    00162                                                          0, 1, 9,511, 10,1021, 11,2041, 12,4081, 13,8161, 14,16321, 15,32641, 16,65281};
    00163         */
    00164         err = CalcGridPoints4Cube(*theCubeSize, inputDim, &gridPoints, &needBits);
    00165         if (err)
    00166                 goto CleanupAndExit;
    00167
    00168         theSize = 1;
    00169         aExtraSize = 1;
    00170         for( i=0; i<(inputDim-1); ++i){ /* Extra Size for Interpolation */
    00171                 theSize *= gridPoints;
    00172                 aExtraSize += theSize;
    00173         }
    00174
    00175 #ifdef ALLOW_MMX
    00176         aExtraSize++;   /* +1 for MMX 4 Byte access */
    00177 #endif
    00178     theSize *= gridPoints;
    00179
    00180         *theExtraSize = aExtraSize;
    00181         *theCubeSize = theSize * inputDim;
    00182         tempCube = ALLOC_DATA( (theSize+aExtraSize) * inputDim*2, &err);
    00183         if (err != noErr)
    00184                 goto CleanupAndExit;
    00185         LOCK_DATA(tempCube);
    00186         cube = (UINT16*)DATA_2_PTR(tempCube);
    00187
    00188         if( inputDim == 3)
    00189         {
    00190                 register long  aShift;
    00191                 register long  j,k;
    00192                 register UINT16 aI, aJ, aK;
    00193                 aShift = (16 - needBits) ;
    00194                 /*
    00195                 aShift = DivisionReplace[2*needBits] - (8 - needBits) ;
    00196                 if( aShift < 0 ){
    00197                         aFactor = DivisionReplace[2*needBits+1]*(1<<(-aShift));
    00198                         aShift = 0;
    00199                 }
    00200                 else aFactor = DivisionReplace[2*needBits+1];
    00201                 */
    00202                 for( i=0; i<gridPoints; ++i){
    00203                         aI = (UINT16)(i<< aShift);
    00204                         aI |= aI >> needBits;
    00205                         aI |= aI >> (2*needBits);
    00206                         aI |= aI >> (4*needBits);
    00207                         for( j=0; j<gridPoints; ++j){
    00208                                 aJ = (UINT16)(j<< aShift);
    00209                                 aJ |= aJ >> needBits;
    00210                                 aJ |= aJ >> (2*needBits);
    00211                                 aJ |= aJ >> (4*needBits);
    00212                                 for( k=0; k<gridPoints; ++k){
    00213                                         *cube++ = aI;
    00214                                         *cube++ = aJ;
    00215                                         aK = (UINT16)(k<< aShift);
    00216                                         aK |= aK >> needBits;
    00217                                         aK |= aK >> (2*needBits);
    00218                                         aK |= aK >> (4*needBits);
    00219                                         *cube++ = aK;
    00220                                 }
    00221                         }
    00222                 }
    00223         }
    00224         else if( inputDim == 4)
    00225         {
    00226                 register long  aShift;
    00227                 register long  j,k,l;
    00228                 register UINT16 aI, aJ, aK, aL;
    00229                 aShift = (16 - needBits) ;
    00230                 /*
    00231                 aShift = DivisionReplace[2*needBits] - (8 - needBits) ;
    00232                 if( aShift < 0 ){
    00233                         aFactor = DivisionReplace[2*needBits+1]*(1<<(-aShift));
    00234                         aShift = 0;
    00235                 }
    00236                 else aFactor = DivisionReplace[2*needBits+1];
    00237                 */
    00238                 for( i=0; i<gridPoints; ++i){
    00239                         aI = (UINT16)(i<< aShift);
    00240                         aI |= aI >> needBits;
    00241                         aI |= aI >> (2*needBits);
    00242                         aI |= aI >> (4*needBits);
    00243                         for( j=0; j<gridPoints; ++j){
    00244                                 aJ = (UINT16)(j<< aShift);
    00245                                 aJ |= aJ >> needBits;
    00246                                 aJ |= aJ >> (2*needBits);
    00247                                 aJ |= aJ >> (4*needBits);
    00248                                 for( k=0; k<gridPoints; ++k){
    00249                                         aK = (UINT16)(k<< aShift);
    00250                                         aK |= aK >> needBits;
    00251                                         aK |= aK >> (2*needBits);
    00252                                         aK |= aK >> (4*needBits);
    00253                                         for( l=0; l<gridPoints; ++l){
    00254                                                 *cube++ = aI;
    00255                                                 *cube++ = aJ;
    00256                                                 *cube++ = aK;
    00257                                                 aL = (UINT16)(l<< aShift);
    00258                                                 aL |= aL >> needBits;
    00259                                                 aL |= aL >> (2*needBits);
    00260                                                 aL |= aL >> (4*needBits);
    00261                                                 *cube++ = aL;
    00262                                         }
    00263                                 }
    00264                         }
    00265                 }
    00266         }
    00267         else
    00268         {
    00269                 SetValues16( 0, inputDim, needBits, &cube );
    00270         }
    00271         *theBits = needBits;
    00272         UNLOCK_DATA(tempCube);
    00273         *theCube = tempCube;
    00274 CleanupAndExit:
    00275         LH_END_PROC("MakeCube16")
    00276         return err;
    00277 }