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