00065 {
00066
LH_UINT8 * inputData[8], *outputData[8];
00067
UINT32 InputIncrement, OutputIncrement, inputDataRowOffset, outputDataRowOffset, Pixelcount, LineCount;
00068
register unsigned long adr0;
00069
register unsigned long ko0;
00070
unsigned long accu[8];
00071
register long i;
00072
00073
00074
register unsigned long nDim;
00075
register long aElutShift,aAlutShift,aElutOffset,aAlutOffset;
00076
register unsigned long aElutAdrSize;
00077
register long aElutAdrShift;
00078
register long aElutWordSize;
00079
register long aAlutAdrSize;
00080
register long aAlutAdrShift;
00081
register long aAlutWordSize;
00082
register unsigned long aXlutInDim;
00083
register unsigned long aXlutOutDim;
00084
register long aXlutAdrSize;
00085
register long aXlutAdrShift;
00086
register unsigned long aXlutWordSize;
00087
register long aInputPackMode8Bit;
00088
register long aOutputPackMode8Bit;
00089
register long aElutShiftNum;
00090
register unsigned long ii,jj;
00091
LH_UINT16 ein_Cache[8];
00092
00093
00094
LH_UINT16 * aus_lut = (
LH_UINT16*)lutParam->
outputLut;
00095
LH_UINT16 * ein_lut = (
LH_UINT16*)lutParam->
inputLut;
00096
LH_UINT16 * Xlut = (
LH_UINT16*)lutParam->
colorLut;
00097
00098
Boolean aCopyAlpha;
00099
00100
#ifdef DEBUG_OUTPUT
00101
long err =
noErr;
00102
#endif
00103
LH_START_PROC(
"CalcNDim_Data8To8_Lut16")
00104 #
if UNROLL_NDIM
00105
if( lutParam->
colorLutInDim == 3 &&
00106 calcParam->
cmInputPixelOffset == 6 ){
00107
if( lutParam->
colorLutOutDim == 3 &&
00108 ( calcParam->
cmOutputPixelOffset == 3 ||
00109 calcParam->
cmOutputPixelOffset == 6)){
00110
return Calc323Dim_Data8To8_Lut16( calcParam, lutParam );
00111 }
00112
if( lutParam->
colorLutOutDim == 4 &&
00113 ( calcParam->
cmOutputPixelOffset == 4 ||
00114 calcParam->
cmOutputPixelOffset == 8) ){
00115
return Calc324Dim_Data8To8_Lut16( calcParam, lutParam );
00116 }
00117 }
00118
if( lutParam->
colorLutInDim == 4 &&
00119 calcParam->
cmInputPixelOffset == 8 ){
00120
if( lutParam->
colorLutOutDim == 3 &&
00121 ( calcParam->
cmOutputPixelOffset == 3 ||
00122 calcParam->
cmOutputPixelOffset == 6) ){
00123
return Calc423Dim_Data8To8_Lut16( calcParam, lutParam );
00124 }
00125
if( lutParam->
colorLutOutDim == 4 &&
00126 ( calcParam->
cmOutputPixelOffset == 4 ||
00127 calcParam->
cmOutputPixelOffset == 8) ){
00128
return Calc424Dim_Data8To8_Lut16( calcParam, lutParam );
00129 }
00130 }
00131
#endif
00132
00133 inputData[0] = (
LH_UINT8 *)calcParam->
inputData[0];
00134 inputData[1] = (
LH_UINT8 *)calcParam->
inputData[1];
00135 inputData[2] = (
LH_UINT8 *)calcParam->
inputData[2];
00136 inputData[3] = (
LH_UINT8 *)calcParam->
inputData[3];
00137 inputData[4] = (
LH_UINT8 *)calcParam->
inputData[4];
00138 inputData[5] = (
LH_UINT8 *)calcParam->
inputData[5];
00139 inputData[6] = (
LH_UINT8 *)calcParam->
inputData[6];
00140 inputData[7] = (
LH_UINT8 *)calcParam->
inputData[7];
00141
00142 outputData[0] = (
LH_UINT8 *)calcParam->
outputData[0];
00143 outputData[1] = (
LH_UINT8 *)calcParam->
outputData[1];
00144 outputData[2] = (
LH_UINT8 *)calcParam->
outputData[2];
00145 outputData[3] = (
LH_UINT8 *)calcParam->
outputData[3];
00146 outputData[4] = (
LH_UINT8 *)calcParam->
outputData[4];
00147 outputData[5] = (
LH_UINT8 *)calcParam->
outputData[5];
00148 outputData[6] = (
LH_UINT8 *)calcParam->
outputData[6];
00149 outputData[7] = (
LH_UINT8 *)calcParam->
outputData[7];
00150 InputIncrement = calcParam->
cmInputPixelOffset;
00151 OutputIncrement = calcParam->
cmOutputPixelOffset;
00152 inputDataRowOffset = calcParam->
cmInputBytesPerLine - calcParam->
cmPixelPerLine * calcParam->
cmInputPixelOffset + InputIncrement;
00153 outputDataRowOffset = calcParam->
cmOutputBytesPerLine - calcParam->
cmPixelPerLine * calcParam->
cmOutputPixelOffset + OutputIncrement;
00154
00155 Pixelcount = calcParam->
cmPixelPerLine;
00156 LineCount = calcParam->
cmLineCount;
00157
00158 aElutAdrSize = lutParam->
inputLutEntryCount;
00159
for ( i = 1; (i < 32) && (aElutAdrSize >> i); i++)
00160 aElutAdrShift = i;
00161 aElutWordSize = lutParam->
inputLutWordSize;
00162 aAlutAdrSize = lutParam->
outputLutEntryCount;
00163
for ( i = 1; (i < 32) && (aAlutAdrSize >> i); i++)
00164 aAlutAdrShift = i;
00165 aAlutWordSize = lutParam->
outputLutWordSize;
00166 aXlutInDim = lutParam->
colorLutInDim;
00167 aXlutOutDim = lutParam->
colorLutOutDim;
00168 aXlutAdrSize = lutParam->
colorLutGridPoints;
00169
for ( i = 1; (i < 32) && (aXlutAdrSize >> i); i++)
00170 aXlutAdrShift = i;
00171 aXlutWordSize = lutParam->
colorLutWordSize;
00172
00173 aInputPackMode8Bit = calcParam->
cmInputColorSpace &
cm8PerChannelPacking || calcParam->
cmInputColorSpace &
cmLong8ColorPacking;
00174 aOutputPackMode8Bit = calcParam->
cmOutputColorSpace &
cm8PerChannelPacking || calcParam->
cmOutputColorSpace &
cmLong8ColorPacking;
00175
00176
00177
#if FARBR_FILES
00178
WriteLuts(
"DoNDim",1,aElutAdrSize,aElutWordSize,ein_lut,
00179 aXlutInDim,aXlutOutDim,aXlutAdrSize,aXlutWordSize,(LH_UINT16 *)Xlut,aAlutAdrSize,aAlutWordSize,(LH_UINT16 *)aus_lut);
00180
#endif
00181
00182 i=0;
00183
00184
00185
if( calcParam->
copyAlpha )aCopyAlpha = 1;
00186
else aCopyAlpha = 0;
00187
if( aXlutInDim > 7 || aXlutOutDim > 7 )aCopyAlpha = 0;
00188
if( aInputPackMode8Bit != aOutputPackMode8Bit )aCopyAlpha = 0;
00189
00190 nDim=aXlutInDim;
00191
00192
if( aInputPackMode8Bit ){
00193
aElutShift = aElutAdrShift-8;
00194
if(
aElutShift < 0 )
00195 {
00196
#ifdef DEBUG_OUTPUT
00197
DebugPrint(
"� DoNDim-Error: aElutShift < 0 (aElutShift = %d)\n",aElutShift);
00198
#endif
00199
return cmparamErr;
00200 }
00201 }
00202
else{
00203
aElutShift = 16-aElutAdrShift;
00204
if(
aElutShift < 0 )
00205 {
00206
#ifdef DEBUG_OUTPUT
00207
DebugPrint(
"� DoNDim-Error: aElutShift < 0 (aElutShift = %d)\n",aElutShift);
00208
#endif
00209
return cmparamErr;
00210 }
00211 }
00212
00213
if( aOutputPackMode8Bit ){
00214 aAlutShift = (aAlutWordSize-8);
00215 }
00216
else{
00217 aAlutShift = (16 - aAlutWordSize);
00218 }
00219
00220
#ifdef DEBUG_OUTPUT
00221
if ( DebugCheck(kThisFile, kDebugReserved1) ){
00222
DebugPrint(
"aElutAdrSize=%lx,aElutAdrShift=%lx,aElutWordSize=%lx,ein_lut=%lx,\n",
00223 aElutAdrSize,aElutAdrShift,aElutWordSize,ein_lut);
00224
DebugPrint(
"aAlutAdrSize=%lx,aAlutAdrShift=%lx,aAlutWordSize=%lx,aus_lut=%lx,\n",
00225 aAlutAdrSize,aAlutAdrShift,aAlutWordSize,aus_lut);
00226
DebugPrint(
"aXlutInDim=%lx,aXlutOutDim=%lx,aXlutAdrSize=%lx,aXlutAdrShift=%lx,aXlutWordSize=%lx,Xlut=%lx,\n",
00227 aXlutInDim,aXlutOutDim,aXlutAdrSize,aXlutAdrShift,aXlutWordSize,Xlut);
00228
DebugPrint(
"aInputPackMode8Bit=%lx,aOutputPackMode8Bit=%lx\n",
00229 aInputPackMode8Bit,aOutputPackMode8Bit );
00230 }
00231
#endif
00232
aElutShiftNum = 1<<
aElutShift;
00233
00234
00235
if( aXlutAdrSize != (1<<aXlutAdrShift )){
00236
register long aXlutOffset;
00237
#if FARBR_DEBUG
00238
register long aXlutPlaneOffset;
00239
#endif
00240
long theXlutOffsets[8];
00241
register unsigned long aAlutInShift;
00242
register long aAlutInShiftRemainder;
00243
register unsigned long aAlutInShiftNum;
00244
register long aElutWordSizeMask = (1<<aElutWordSize) - 1;
00245
register unsigned long aAlutRound;
00246 aAlutInShift = aXlutWordSize + aElutWordSize - aAlutAdrShift;
00247 aAlutInShiftRemainder = 0;
00248
if( aAlutInShift > 16 ){
00249 aAlutInShiftRemainder = aAlutInShift - 16;
00250 aAlutInShift = 16;
00251 }
00252 aAlutInShiftNum = (1<<aAlutInShift);
00253
00254
#ifdef DEBUG_OUTPUT
00255
if ( DebugCheck(kThisFile, kDebugMiscInfo) )
00256
DebugPrint(
" DoNDim gripoints = %ld\n",aXlutAdrSize);
00257
#endif
00258
if( aElutWordSize <= 0 ){
00259
#ifdef DEBUG_OUTPUT
00260
DebugPrint(
"� DoNDim-Error: (1<<aElutWordSize)/aXlutAdrSize <= 0 %d\n",(1<<aElutWordSize)/aXlutAdrSize);
00261
#endif
00262
return cmparamErr;
00263 }
00264
if( aAlutInShift <= 0 ){
00265
#ifdef DEBUG_OUTPUT
00266
DebugPrint(
"� DoNDim-Error: aAlutInShift <= 0 %d\n",aAlutInShift);
00267
#endif
00268
return cmparamErr;
00269 }
00270 aXlutOffset =aXlutOutDim;
00271
for( i=0; i<(
long)nDim; i++){
00272 theXlutOffsets[ nDim-1-i] = aXlutOffset;
00273 aXlutOffset *=aXlutAdrSize;
00274 }
00275 aAlutRound = 1<<( aAlutInShift + aAlutShift - 1 );
00276
00277
#ifdef DEBUG_OUTPUT
00278
if ( DebugCheck(kThisFile, kDebugReserved1) )
00279
DebugPrint(
" aElutWordSize((1<<aElutWordSize)-0) = %ld\n aAlutInShift:((1<<aXlutWordSize)*aElutWordSize+(aAlutAdrSize/2))/aAlutAdrSize = %ld\n",aElutWordSize,aAlutInShift);
00280
#endif
00281
00282
while (LineCount){
00283 i = Pixelcount;
00284
00285
while (i){
00286
00287
long adr[8],
Index[8];
00288
LH_UINT16 ein_reg[8];
00289
register unsigned long adrAdr,ko,adrOffset;
00290
00291 adr0=0;
00292 aElutOffset = 0;
00293 jj=0;
00294
if( aInputPackMode8Bit ){
00295
for( ii=0; ii<nDim; ii++){
00296 jj=ein_lut[((*(
LH_UINT8 *)&ein_Cache[ii]=*inputData[ii])<<
aElutShift)+aElutOffset];
00297 jj *= aXlutAdrSize;
00298 aElutOffset += aElutAdrSize;
00299 adr[ii] = jj & aElutWordSizeMask;
00300 jj = jj >> aElutWordSize;
00301 adr0 += (jj)*theXlutOffsets[ii];
00302 ein_reg[ii] = (
LH_UINT16)jj;
00303 }
00304 }
00305
else{
00306
for( ii=0; ii<nDim; ii++){
00307 jj=ein_Cache[ii]=(*(
LH_UINT16 *)inputData[ii]);
00308 ko0 = jj - ( jj >> ( aElutAdrShift ));
00309 ko = ko0 & (
aElutShiftNum - 1 );
00310 ko0 = ko0 >>
aElutShift;
00311 ko0 += aElutOffset;
00312 jj = ( ein_lut[ ko0 ] * (
aElutShiftNum - ko ) + ein_lut[ ko0 +1 ] * ko ) >>
aElutShift;
00313
00314 jj *= aXlutAdrSize;
00315 aElutOffset += aElutAdrSize;
00316 adr[ii] = jj & aElutWordSizeMask;
00317 jj = jj >> aElutWordSize;
00318 adr0 += (jj)*theXlutOffsets[ii];
00319 ein_reg[ii] = (
LH_UINT16)jj;
00320 }
00321 }
00322
00323
#if FARBR_DEBUG
00324
aXlutPlaneOffset = nDim;
00325
DebugPrint(
"i=%ld o=%ld\n",i,o);
00326
if( aInputPackMode < k3ShortsUnpacked ){
DebugPrint(
"ein_arr=(d)");
for(ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",ein_arr[i+ii]);
DebugPrint(
"\n");}
00327
else{
DebugPrint(
"ein_arr=(d)");
for(ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",aEinArr[i+ii]);
DebugPrint(
"\n");}
00328
DebugPrint(
"ein_reg=(d)");
for(ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",ein_reg[ii]/aXlutAdrSize);
DebugPrint(
"\n");
00329
DebugPrint(
"adr=(d)");
for( ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",adr[ii] );
DebugPrint(
"\n");
00330
#endif
00331
00332 {
00333
register unsigned long Top, Gap;
00334
register long Hold,Switches;
00335
00336 Gap = nDim;
00337
00338
for( ii=0; ii<nDim; ++ii){
00339
Index[ii] = ii;
00340 }
00341
do{
00342
00343 Gap = (Gap * ((10*16)/
SHRINK_FACTOR) ) >>4;
00344
if( Gap == 0 ) Gap = 1;
00345 Switches = 0;
00346 Top = nDim - Gap;
00347
for( ii=0; ii<Top; ++ii){
00348 jj = ii + Gap;
00349
if( adr[
Index[ii]] < adr[
Index[jj]] ){
00350
Hold =
Index[ii];
00351
Index[ii] =
Index[jj];
00352
Index[jj] =
Hold;
00353 Switches = 1;
00354 }
00355 }
00356 }
while( Switches || Gap > 1 );
00357 }
00358
#if FARBR_DEBUG
00359
DebugPrint(
"Index=");
00360
for( ii=0; ii<nDim; ++ii){
00361
DebugPrint(
"%3ld ",Index[ii] );
00362 }
00363
DebugPrint(
"\n");
00364
#endif
00365
00366
for( jj=0; jj<aXlutOutDim; ++jj)accu[jj]=0;
00367
00368 ko0 = (1<<aElutWordSize);
00369 adrAdr=adr0;
00370 adrOffset=0;
00371
if( aXlutWordSize == 16 ){
00372
for( ii=0; ii<nDim; ++ii){
00373 jj =
Index[ii];
00374 ko = ko0 - adr[jj];
00375 ko0 = adr[jj];
00376
00377
if( ein_reg[jj] < (
LH_UINT16)(aXlutAdrSize-1) )
00378 adrOffset += theXlutOffsets[jj];
00379
00380
for( jj=0; jj<aXlutOutDim; ++jj){
00381
#if FARBR_DEBUG
00382
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj*aXlutPlaneOffset),Xlut[adrAdr+(jj*aXlutPlaneOffset)],ko);
00383
#endif
00384
accu[jj]+=Xlut[adrAdr+(jj)]*ko;
00385 }
00386
00387 adrAdr = (adr0 + adrOffset);
00388 }
00389
for( jj=0; jj<aXlutOutDim; ++jj){
00390
#if FARBR_DEBUG
00391
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj*aXlutPlaneOffset),Xlut[adrAdr+(jj*aXlutPlaneOffset)],ko0);
00392
#endif
00393
accu[jj]+=Xlut[adrAdr+jj]*ko0;
00394 }
00395 }
00396
else{
00397
00398
for( ii=0; ii<nDim; ++ii){
00399 jj =
Index[ii];
00400 ko = ko0 - adr[jj];
00401 ko0 = adr[jj];
00402
00403
if( ein_reg[jj] < (
LH_UINT16)(aXlutAdrSize-1) )
00404 adrOffset += theXlutOffsets[jj];
00405
00406
for( jj=0; jj<aXlutOutDim; ++jj){
00407
#if FARBR_DEBUG
00408
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj*aXlutPlaneOffset),Xlut[adrAdr+(jj*aXlutPlaneOffset)],ko);
00409
#endif
00410
accu[jj]+=((
LH_UINT8 *)Xlut)[adrAdr+(jj)]*ko;
00411 }
00412
00413 adrAdr = (adr0 + adrOffset);
00414 }
00415
for( jj=0; jj<aXlutOutDim; ++jj){
00416
#if FARBR_DEBUG
00417
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj*aXlutPlaneOffset),Xlut[adrAdr+(jj*aXlutPlaneOffset)],ko0);
00418
#endif
00419
accu[jj]+=((
LH_UINT8 *)Xlut)[adrAdr+jj]*ko0;
00420
00421
00422 }
00423 }
00424
00425
#if FARBR_DEBUG
00426
DebugPrint(
"accu=(d)");
for( ii=0; ii<aXlutOutDim; ++ii)
DebugPrint(
"%3ld ",accu[ii] );
DebugPrint(
"\n");
00427
#endif
00428
aAlutOffset = 0;
00429
00430
if( aOutputPackMode8Bit ){
00431
for( ii=0; ii<aXlutOutDim; ++ii){
00432
#if FARBR_DEBUG
00433
ii = ((accu[ii]) >> aAlutInShift)+aAlutOffset;
00434
DebugPrint(
"adr:((accu[ii]) >> aAlutInShift)+aAlutOffset = %ld\n",ii);
00435
DebugPrint(
"aus_lut[%ld]=%ld aus_lut[%ld]=%ld aus_lut[%ld]=%ld \n",ii-1,aus_lut[ii-1],ii,aus_lut[ii],ii+1,aus_lut[ii+1]);
00436
#endif
00437
jj = accu[ii];
00438 jj = jj + ( jj >> aXlutWordSize );
00439
00440 ko0 = (jj - ( jj >> ( aAlutAdrShift ))) >> aAlutInShiftRemainder;
00441
00442 ko = ko0 & (aAlutInShiftNum - 1 );
00443 ko0 = ko0 >> aAlutInShift;
00444 ko0 += aAlutOffset;
00445
if( aAlutWordSize <= 8)
00446 jj = ( ((
LH_UINT8*)aus_lut)[ ko0 ] * ( aAlutInShiftNum - ko ) + ((
LH_UINT8*)aus_lut)[ ko0 +1 ] * ko ) >> ( aAlutInShift );
00447
else{
00448 jj = ( aus_lut[ ko0 ] * ( aAlutInShiftNum - ko ) + aus_lut[ ko0 +1 ] * ko );
00449 jj = jj - ( jj >> aAlutShift );
00450 jj = ( jj + aAlutRound ) >> (aAlutInShift + aAlutShift);
00451 }
00452 *outputData[ii] = (
LH_UINT8)jj;
00453 aAlutOffset += aAlutAdrSize;
00454 }
00455 }
00456
else{
00457
if( aXlutWordSize >= 16 ){
00458
for( ii=0; ii<aXlutOutDim; ++ii){
00459 jj = accu[ii];
00460 jj = jj + ( jj >> aXlutWordSize );
00461 ko0 = (jj - ( jj >> ( aAlutAdrShift ))) >> aAlutInShiftRemainder;
00462
00463 ko = ko0 & (aAlutInShiftNum - 1 );
00464 ko0 = ko0 >> aAlutInShift;
00465 ko0 += aAlutOffset;
00466
if( aAlutWordSize <= 8)
00467 jj = ( ((
LH_UINT8*)aus_lut)[ ko0 ] * ( aAlutInShiftNum - ko ) + ((
LH_UINT8*)aus_lut)[ ko0 +1 ] * ko ) << ( aAlutShift - aAlutInShift );
00468
else
00469 jj = ( aus_lut[ ko0 ] * ( aAlutInShiftNum - ko ) + aus_lut[ ko0 +1 ] * ko ) >> (aAlutInShift- aAlutShift);
00470 *((
LH_UINT16 *)outputData[ii]) = (
LH_UINT16)jj;
00471 aAlutOffset += aAlutAdrSize;
00472 }
00473 }
00474
else{
00475
for( ii=0; ii<aXlutOutDim; ++ii){
00476 jj = accu[ii];
00477 jj = jj + ( jj >> aXlutWordSize ) + ( jj >> 2*aXlutWordSize );
00478 ko0 = (jj - ( jj >> ( aAlutAdrShift ))) ;
00479
00480 ko = ko0 & (aAlutInShiftNum - 1 );
00481 ko0 = ko0 >> aAlutInShift;
00482 ko0 += aAlutOffset;
00483
if( aAlutWordSize <= 8)
00484 jj = ( ((
LH_UINT8*)aus_lut)[ ko0 ] * ( aAlutInShiftNum - ko ) + ((
LH_UINT8*)aus_lut)[ ko0 +1 ] * ko ) << ( aAlutShift - aAlutInShift );
00485
else
00486 jj = ( aus_lut[ ko0 ] * ( aAlutInShiftNum - ko ) + aus_lut[ ko0 +1 ] * ko ) >> (aAlutInShift- aAlutShift);
00487 *((
LH_UINT16 *)outputData[ii]) = (
LH_UINT16)jj;
00488 aAlutOffset += aAlutAdrSize;
00489 }
00490 }
00491 }
00492
#if FARBR_DEBUG
00493
if( aOutputPackMode8Bit ){
DebugPrint(
"outputData=(d)");
for( ii=0; ii<aXlutOutDim; ++ii)
DebugPrint(
"%3ld ",outputData[ii+o] );
DebugPrint(
"\n");}
00494
else{
DebugPrint(
"outputData=(d)");
for( ii=0; ii<aXlutOutDim; ++ii)
DebugPrint(
"%3ld ",aAusArr[ii+o] );
DebugPrint(
"\n");}
00495
#endif
00496
if( aCopyAlpha ){
00497
if( aOutputPackMode8Bit )
00498 *outputData[aXlutOutDim] = *inputData[aXlutInDim];
00499
else
00500 *((
LH_UINT16 *)outputData[aXlutOutDim]) = *((
LH_UINT16 *)inputData[aXlutInDim]);
00501 }
00502
while (--i){
00503
for( jj=0; jj<aXlutInDim; ++jj){
00504 inputData[jj] += InputIncrement;
00505 }
00506
for( jj=0; jj<aXlutOutDim; ++jj){
00507 outputData[jj] += OutputIncrement;
00508 }
00509
if( aCopyAlpha ){
00510 inputData[aXlutInDim] += InputIncrement;
00511 outputData[aXlutOutDim] += OutputIncrement;
00512 }
00513
00514
if( aInputPackMode8Bit ){
00515
for( jj=0; jj<aXlutInDim; ++jj){
00516
if( *inputData[jj] ^ *(
LH_UINT8 *)(&ein_Cache[jj]) )
break;
00517 }
00518 }
00519
else{
00520
for( jj=0; jj<aXlutInDim; ++jj){
00521
if( *((
LH_UINT16 *)inputData[jj]) ^ ein_Cache[jj] )
break;
00522 }
00523 }
00524
if( jj<aXlutInDim )
break;
00525
if( aOutputPackMode8Bit ){
00526
for( jj=0; jj<aXlutOutDim; ++jj){
00527 *outputData[jj] = outputData[jj][-(
long)OutputIncrement];
00528 }
00529
if( aCopyAlpha ){
00530 *outputData[aXlutOutDim] = *inputData[aXlutInDim];
00531 }
00532 }
00533
else{
00534
for( jj=0; jj<aXlutOutDim; ++jj){
00535 *((
LH_UINT16 *)outputData[jj]) = *(
LH_UINT16 *)(&outputData[jj][-(
long)OutputIncrement]);
00536 }
00537
if( aCopyAlpha ){
00538 *((
LH_UINT16 *)outputData[aXlutOutDim]) = *((
LH_UINT16 *)inputData[aXlutInDim]);
00539 }
00540 }
00541 }
00542 }
00543
00544
if( --LineCount ){
00545
for( jj=0; jj<aXlutInDim; ++jj){
00546 inputData[jj] += inputDataRowOffset;
00547 }
00548
for( jj=0; jj<aXlutOutDim; ++jj){
00549 outputData[jj] += outputDataRowOffset;
00550 }
00551
if( aCopyAlpha ){
00552 inputData[aXlutInDim] += inputDataRowOffset;
00553 outputData[aXlutOutDim] += outputDataRowOffset;
00554 }
00555 }
00556 }
00557 }
00558
else{
00559
00560
register unsigned long bit_breit_selektor;
00561
register unsigned long bit_maske_selektor;
00562
register unsigned long bit_breit_adr;
00563
register unsigned long bit_maske_adr;
00564
register unsigned long aAlutInShiftNum;
00565
register long aAlutInShift;
00566
register long aAlutInShiftRemainder;
00567
register unsigned long aAlutRound;
00568
00569 bit_breit_selektor=aElutWordSize-aXlutAdrShift;
00570
if( aElutWordSize-aXlutAdrShift < 0 )
00571 {
00572
#ifdef DEBUG_OUTPUT
00573
DebugPrint(
"� DoNDim-Error: bit_breit_selektor < 0 (bit_breit_selektor = %d)\n",bit_breit_selektor);
00574
#endif
00575
return cmparamErr;
00576 }
00577 bit_maske_selektor=(1<<bit_breit_selektor)-1;
00578 bit_breit_adr=aXlutAdrShift;
00579 bit_maske_adr=((1<<bit_breit_adr)-1)<<bit_breit_selektor;
00580 aAlutInShift = (aXlutWordSize+bit_breit_selektor-aAlutAdrShift);
00581
00582 aAlutInShiftRemainder = 0;
00583
if( aAlutInShift > 16 ){
00584 aAlutInShiftRemainder = aAlutInShift - 16;
00585 aAlutInShift = 16;
00586 }
00587
00588 aAlutInShiftNum = (1<<aAlutInShift);
00589
00590 aAlutRound = 1<<( aAlutInShift + aAlutShift - 1 );
00591
while (LineCount){
00592 i = Pixelcount;
00593
00594
while (i){
00595
00596
long adr[8],
Index[8];
00597
00598
LH_UINT16 ein_reg[8];
00599
register unsigned long adrAdr,ko,adrOffset;
00600
00601
00602 adr0=0;
00603 aElutOffset = 0;
00604 jj=0;
00605
if( aInputPackMode8Bit ){
00606
for( ii=0; ii<nDim; ii++){
00607 jj=ein_lut[((*(
LH_UINT8 *)&ein_Cache[ii]=*inputData[ii])<<
aElutShift)+aElutOffset];
00608 aElutOffset += aElutAdrSize;
00609 adr[ii] = (jj & bit_maske_selektor);
00610 adr0 |= ((jj & bit_maske_adr)>>bit_breit_selektor)<<((nDim-ii-1)*bit_breit_adr);
00611 ein_reg[ii] = (
LH_UINT16)jj;
00612 }
00613 }
00614
else{
00615
for( ii=0; ii<nDim; ii++){
00616 jj=ein_Cache[ii]=(*(
LH_UINT16 *)inputData[ii]);
00617 ko0 = jj - ( jj >> ( aElutAdrShift ));
00618 ko = ko0 & (
aElutShiftNum - 1 );
00619 ko0 = ko0 >>
aElutShift;
00620 ko0 += aElutOffset;
00621 jj = ( ein_lut[ ko0 ] * (
aElutShiftNum - ko ) + ein_lut[ ko0 +1 ] * ko ) >>
aElutShift;
00622
00623 aElutOffset += aElutAdrSize;
00624 adr[ii] = (jj & bit_maske_selektor);
00625 adr0 |= ((jj & bit_maske_adr)>>bit_breit_selektor)<<((nDim-ii-1)*bit_breit_adr);
00626 ein_reg[ii] = (
LH_UINT16)jj;
00627 }
00628 }
00629
00630 adr0 *= aXlutOutDim;
00631
#if FARBR_DEBUG
00632
DebugPrint(
"i=%ld o=%ld\n",i,o);
00633
DebugPrint(
"adr0=%ld\n",adr0);
00634
if( aInputPackMode < k3ShortsUnpacked ){
DebugPrint(
"ein_arr=(d)");
for(ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",ein_arr[i+ii]);
DebugPrint(
"\n");}
00635
else{
DebugPrint(
"ein_arr=(d)");
for(ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",aEinArr[i+ii]);
DebugPrint(
"\n");}
00636
DebugPrint(
"ein_reg=(d)");
for(ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",ein_reg[ii]);
DebugPrint(
"\n");
00637
DebugPrint(
"adr=(d)");
for( ii=0; ii<nDim; ++ii)
DebugPrint(
"%ld ",adr[ii] );
DebugPrint(
"\n");
00638
#endif
00639
00640 {
00641
register unsigned long Top, Gap;
00642
register long Hold,Switches;
00643
00644 Gap = nDim;
00645
00646
for( ii=0; ii<nDim; ++ii){
00647
Index[ii] = ii;
00648 }
00649
do{
00650
00651 Gap = (Gap * ((10*16)/
SHRINK_FACTOR) ) >>4;
00652
if( Gap == 0 ) Gap = 1;
00653 Switches = 0;
00654 Top = nDim - Gap;
00655
for( ii=0; ii<Top; ++ii){
00656 jj = ii + Gap;
00657
if( adr[
Index[ii]] < adr[
Index[jj]] ){
00658
Hold =
Index[ii];
00659
Index[ii] =
Index[jj];
00660
Index[jj] =
Hold;
00661 Switches = 1;
00662 }
00663 }
00664 }
while( Switches || Gap > 1 );
00665 }
00666
#if FARBR_DEBUG
00667
DebugPrint(
"Index=");
00668
for( ii=0; ii<nDim; ++ii){
00669
DebugPrint(
"%3ld ",Index[ii] );
00670 }
00671
DebugPrint(
"\n");
00672
#endif
00673
00674
for( jj=0; jj<aXlutOutDim; ++jj)accu[jj]=0;
00675
00676 ko0 = bit_maske_selektor+1;
00677 adrAdr=adr0;
00678 adrOffset=0;
00679
00680
if( aXlutWordSize == 16 ){
00681
for( ii=0; ii<nDim; ++ii){
00682 jj =
Index[ii];
00683 ko = ko0 - adr[jj];
00684 ko0 = adr[jj];
00685
00686
if( ein_reg[jj] < bit_maske_adr )
00687 adrOffset |= (1<<(nDim-1-jj)*bit_breit_adr);
00688
00689
for( jj=0; jj<aXlutOutDim; ++jj){
00690
#if FARBR_DEBUG
00691
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj),Xlut[adrAdr+(jj)],ko);
00692
#endif
00693
accu[jj]+=Xlut[adrAdr+(jj)]*ko;
00694 }
00695
00696 adrAdr = (adr0 + aXlutOutDim*adrOffset);
00697 }
00698
for( jj=0; jj<aXlutOutDim; ++jj){
00699
#if FARBR_DEBUG
00700
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj),Xlut[adrAdr+(jj)],ko0);
00701
#endif
00702
accu[jj]+=Xlut[adrAdr+(jj)]*ko0;
00703 }
00704 }
00705
else{
00706
00707
for( ii=0; ii<nDim; ++ii){
00708 jj =
Index[ii];
00709 ko = ko0 - adr[jj];
00710 ko0 = adr[jj];
00711
00712
if( ein_reg[jj] < bit_maske_adr )
00713 adrOffset |= (1<<(nDim-1-jj)*bit_breit_adr);
00714
00715
for( jj=0; jj<aXlutOutDim; ++jj){
00716
#if FARBR_DEBUG
00717
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj),Xlut[adrAdr+(jj)],ko);
00718
#endif
00719
accu[jj]+=((
LH_UINT8 *)Xlut)[adrAdr+(jj)]*ko;
00720 }
00721
00722 adrAdr = (adr0 + aXlutOutDim*adrOffset);
00723 }
00724
for( jj=0; jj<aXlutOutDim; ++jj){
00725
#if FARBR_DEBUG
00726
DebugPrint(
"jj=(d)%ld adrAdr=%lx Address=%lx Xlut[Address]=(d)%ld ko=(d)%ld\n",jj,adrAdr,adrAdr+(jj),Xlut[adrAdr+(jj)],ko0);
00727
#endif
00728
accu[jj]+=((
LH_UINT8 *)Xlut)[adrAdr+(jj)]*ko0;
00729 }
00730 }
00731
00732
#if FARBR_DEBUG
00733
DebugPrint(
"accu=(d)");
for( ii=0; ii<aXlutOutDim; ++ii)
DebugPrint(
"%3ld ",accu[ii] );
DebugPrint(
"\n");
00734
#endif
00735
aAlutOffset = 0;
00736
00737
if( aOutputPackMode8Bit ){
00738
for( ii=0; ii<aXlutOutDim; ++ii){
00739
#if FARBR_DEBUG
00740
ii = ((accu[ii]) >> aAlutInShift)+aAlutOffset;
00741
DebugPrint(
"adr:((accu[ii]) >> aAlutInShift)+aAlutOffset = %ld\n",ii);
00742
DebugPrint(
"aus_lut[%ld]=%ld aus_lut[%ld]=%ld aus_lut[%ld]=%ld \n",ii-1,aus_lut[ii-1],ii,aus_lut[ii],ii+1,aus_lut[ii+1]);
00743
#endif
00744
jj = accu[ii];
00745 jj = jj + ( jj >> aXlutWordSize );
00746
00747 ko0 = (jj - ( jj >> ( aAlutAdrShift ))) >> aAlutInShiftRemainder;
00748
00749 ko = ko0 & (aAlutInShiftNum - 1 );
00750 ko0 = ko0 >> aAlutInShift;
00751 ko0 += aAlutOffset;
00752
if( aAlutWordSize <= 8)
00753 jj = ( ((
LH_UINT8*)aus_lut)[ ko0 ] * ( aAlutInShiftNum - ko ) + ((
LH_UINT8*)aus_lut)[ ko0 +1 ] * ko ) >> ( aAlutInShift );
00754
else{
00755 jj = ( aus_lut[ ko0 ] * ( aAlutInShiftNum - ko ) + aus_lut[ ko0 +1 ] * ko );
00756 jj = jj - ( jj >> aAlutShift );
00757 jj = ( jj + aAlutRound ) >> (aAlutInShift + aAlutShift);
00758 }
00759
00760 *outputData[ii] = (
LH_UINT8)jj;
00761 aAlutOffset += aAlutAdrSize;
00762 }
00763 }
00764
else{
00765
if( aXlutWordSize >= 16 ){
00766
for( ii=0; ii<aXlutOutDim; ++ii){
00767 jj = accu[ii];
00768 jj = jj + ( jj >> aXlutWordSize );
00769 ko0 = (jj - ( jj >> ( aAlutAdrShift ))) >> aAlutInShiftRemainder;
00770
00771 ko = ko0 & (aAlutInShiftNum - 1 );
00772 ko0 = ko0 >> aAlutInShift;
00773 ko0 += aAlutOffset;
00774
if( aAlutWordSize <= 8)
00775 jj = ( ((
LH_UINT8*)aus_lut)[ ko0 ] * ( aAlutInShiftNum - ko ) + ((
LH_UINT8*)aus_lut)[ ko0 +1 ] * ko ) << ( aAlutShift - aAlutInShift );
00776
else
00777 jj = ( aus_lut[ ko0 ] * ( aAlutInShiftNum - ko ) + aus_lut[ ko0 +1 ] * ko ) >> (aAlutInShift- aAlutShift);
00778 *((
LH_UINT16 *)outputData[ii]) = (
LH_UINT16)jj;
00779 aAlutOffset += aAlutAdrSize;
00780 }
00781 }
00782
else{
00783
for( ii=0; ii<aXlutOutDim; ++ii){
00784 jj = accu[ii];
00785 jj = jj + ( jj >> aXlutWordSize ) + ( jj >> 2*aXlutWordSize );
00786 ko0 = (jj - ( jj >> ( aAlutAdrShift )));
00787
00788 ko = ko0 & (aAlutInShiftNum - 1 );
00789 ko0 = ko0 >> aAlutInShift;
00790 ko0 += aAlutOffset;
00791
if( aAlutWordSize <= 8)
00792 jj = ( ((
LH_UINT8*)aus_lut)[ ko0 ] * ( aAlutInShiftNum - ko ) + ((
LH_UINT8*)aus_lut)[ ko0 +1 ] * ko ) << ( aAlutShift - aAlutInShift );
00793
else
00794 jj = ( aus_lut[ ko0 ] * ( aAlutInShiftNum - ko ) + aus_lut[ ko0 +1 ] * ko ) >> (aAlutInShift- aAlutShift);
00795 *((
LH_UINT16 *)outputData[ii]) = (
LH_UINT16)jj;
00796 aAlutOffset += aAlutAdrSize;
00797 }
00798 }
00799 }
00800
00801
#if FARBR_DEBUG
00802
if( aOutputPackMode < k3ShortsUnpacked ){
DebugPrint(
"aus_arr=(d)");
for( ii=0; ii<aXlutOutDim; ++ii)
DebugPrint(
"%3ld ",aus_arr[ii+o] );
DebugPrint(
"\n");}
00803
else{
DebugPrint(
"aus_arr=(d)");
for( ii=0; ii<aXlutOutDim; ++ii)
DebugPrint(
"%3ld ",aAusArr[ii+o] );
DebugPrint(
"\n");}
00804
#endif
00805
if( aCopyAlpha ){
00806
if( aOutputPackMode8Bit )
00807 *outputData[aXlutOutDim] = *inputData[aXlutInDim];
00808
else
00809 *((
LH_UINT16 *)outputData[aXlutOutDim]) = *((
LH_UINT16 *)inputData[aXlutInDim]);
00810 }
00811
while (--i){
00812
for( jj=0; jj<aXlutInDim; ++jj){
00813 inputData[jj] += InputIncrement;
00814 }
00815
for( jj=0; jj<aXlutOutDim; ++jj){
00816 outputData[jj] += OutputIncrement;
00817 }
00818
if( aCopyAlpha ){
00819 inputData[aXlutInDim] += InputIncrement;
00820 outputData[aXlutOutDim] += OutputIncrement;
00821 }
00822
00823
if( aInputPackMode8Bit ){
00824
for( jj=0; jj<aXlutInDim; ++jj){
00825
if( *inputData[jj] ^ *(
LH_UINT8 *)(&ein_Cache[jj]) )
break;
00826 }
00827 }
00828
else{
00829
for( jj=0; jj<aXlutInDim; ++jj){
00830
if( *((
LH_UINT16 *)inputData[jj]) ^ ein_Cache[jj] )
break;
00831 }
00832 }
00833
if( jj<aXlutInDim )
break;
00834
if( aOutputPackMode8Bit ){
00835
for( jj=0; jj<aXlutOutDim; ++jj){
00836 *outputData[jj] = outputData[jj][-(
long)OutputIncrement];
00837 }
00838
if( aCopyAlpha ){
00839 *outputData[aXlutOutDim] = *inputData[aXlutInDim];
00840 }
00841 }
00842
else{
00843
for( jj=0; jj<aXlutOutDim; ++jj){
00844 *((
LH_UINT16 *)outputData[jj]) = *(
LH_UINT16 *)(&outputData[jj][-(
long)OutputIncrement]);
00845 }
00846
if( aCopyAlpha ){
00847 *((
LH_UINT16 *)outputData[aXlutOutDim]) = *((
LH_UINT16 *)inputData[aXlutInDim]);
00848 }
00849 }
00850 }
00851 }
00852
00853
if( --LineCount ){
00854
for( jj=0; jj<aXlutInDim; ++jj){
00855 inputData[jj] += inputDataRowOffset;
00856 }
00857
for( jj=0; jj<aXlutOutDim; ++jj){
00858 outputData[jj] += outputDataRowOffset;
00859 }
00860
if( aCopyAlpha ){
00861 inputData[aXlutInDim] += inputDataRowOffset;
00862 outputData[aXlutOutDim] += outputDataRowOffset;
00863 }
00864 }
00865 }
00866 }
00867
00868
00869
00870
00871
00872
LH_END_PROC(
"CalcNDim_Data8To8_Lut16")
00873 return noErr;
00874 }