test: engine1d.c Source File

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

# engine1d.c

Go to the documentation of this file.

    00001 /*
    00002         File:           Engine1D.c
    00003
    00004         Contains:
    00005
    00006         Written by:     U. J. Krabbenhoeft
    00007
    00008         Version:
    00009
    00010         Copyright:      © 1993-1997 by Heidelberger Druckmaschinen AG, all rights reserved.
    00011
    00012 */
    00013
    00014 #define smallCode 1
    00015
    00016 #undef LH_DATA_IN_TYPE
    00017 #undef LH_DATA_OUT_TYPE
    00018 #undef LH_LUT_DATA_TYPE
    00019 #undef LH_DATA_IN_COUNT
    00020 #undef LH_DATA_SHR
    00021 #undef LH_DATA_SHR_CORR
    00022 #undef LH_LUT_DATA_SHR
    00023 #undef LH_BIT_BREIT_INTERNAL
    00024 #if LH_DATA_IN_SIZE_16
    00025 #define LH_DATA_IN_TYPE LH_UINT16
    00026 #else
    00027 #define LH_DATA_IN_TYPE LH_UINT8
    00028 #endif
    00029 #if LH_DATA_OUT_SIZE_16
    00030 #define LH_DATA_OUT_TYPE LH_UINT16
    00031 #else
    00032 #define LH_DATA_OUT_TYPE LH_UINT8
    00033 #endif
    00034 #if LH_LUT_DATA_SIZE_16
    00035 #define LH_BIT_BREIT_INTERNAL   16
    00036 #define LH_LUT_DATA_TYPE LH_UINT16
    00037 #else
    00038 #if LH_DATA_IN_SIZE_16
    00039 #define LH_BIT_BREIT_INTERNAL   16
    00040 #else
    00041 #define LH_BIT_BREIT_INTERNAL   10
    00042 #endif
    00043 #define LH_LUT_DATA_TYPE LH_UINT8
    00044 #endif
    00045
    00046 #if LH_DATA_IN_COUNT_4
    00047 #define LH_DATA_IN_COUNT                4
    00048 #else
    00049 #define LH_DATA_IN_COUNT                3
    00050 #endif
    00051
    00052 #define LH_BIT_MASKE_ADR (((1<<7)-1)<< (LH_BIT_BREIT_INTERNAL-7))
    00053 #define LH_BIT_BREIT_SELEKTOR (LH_BIT_BREIT_INTERNAL-7)
    00054 #define LH_BIT_MASKE_SELEKTOR ((1<<LH_BIT_BREIT_SELEKTOR)-1)
    00055
    00056 #define LH_ADR_BEREICH_SEL              (1<<LH_BIT_BREIT_SELEKTOR)
    00057
    00058 #if LH_LUT_DATA_SIZE_16
    00059 #define LH_DATA_SHR               (16+LH_BIT_BREIT_SELEKTOR-LH_ADR_BREIT_AUS_LUT)  /* z.B. 16+11-10=17 */
    00060 #define LH_DATA_SHR_CORR 8              /* notwendig bei LH_DATA_SHR > 16 */
    00061 #define LH_LUT_DATA_SHR  16             /* Normierung bei Alutinterpolation */
    00062 #else
    00063 #define LH_DATA_SHR               (8+LH_BIT_BREIT_SELEKTOR-LH_ADR_BREIT_AUS_LUT)   /* z.B. 8+7-10=5 */
    00064 #define LH_LUT_DATA_SHR  8              /* Normierung bei Alutinterpolation */
    00065 #endif
    00066
    00067 {
    00068         LH_UINT32 ein_regr;
    00069         LH_DATA_IN_TYPE ein_cache;
    00070         LH_LUT_DATA_TYPE * paNewVal0;
    00071         LH_UINT32 ako0;
    00072
    00073         LH_UINT8        Mode;
    00074         LH_UINT8        LH_DATA_OUT_COUNT = (LH_UINT8)lutParam->colorLutOutDim;
    00075         LH_UINT32       PixelCount, LineCount, i, j;
    00076         long inputOffset,outputOffset;
    00077         LH_DATA_IN_TYPE * input0 = (LH_DATA_IN_TYPE *)calcParam->inputData[0];
    00078         LH_DATA_IN_TYPE * input1 = (LH_DATA_IN_TYPE *)calcParam->inputData[1];
    00079
    00080         LH_DATA_OUT_TYPE * output0 = (LH_DATA_OUT_TYPE *)calcParam->outputData[0];
    00081         LH_DATA_OUT_TYPE * output1 = (LH_DATA_OUT_TYPE *)calcParam->outputData[1];
    00082         LH_DATA_OUT_TYPE * output2 = (LH_DATA_OUT_TYPE *)calcParam->outputData[2];
    00083         LH_DATA_OUT_TYPE * output3 = (LH_DATA_OUT_TYPE *)calcParam->outputData[3];
    00084         LH_DATA_OUT_TYPE * output4 = (LH_DATA_OUT_TYPE *)calcParam->outputData[4];
    00085
    00086         LH_UINT16 * My_InputLut = (LH_UINT16 *)lutParam->inputLut;
    00087         LH_LUT_DATA_TYPE * My_OutputLut = (LH_LUT_DATA_TYPE *)lutParam->outputLut;
    00088         LH_LUT_DATA_TYPE * My_ColorLut = (LH_LUT_DATA_TYPE *)lutParam->colorLut;
    00089
    00090         LH_DATA_OUT_TYPE Mask = (LH_DATA_OUT_TYPE)-1;
    00091
    00092 #ifdef DEBUG_OUTPUT
    00093         CMError err = noErr;
    00094 #endif
    00095         LH_START_PROC(LH_CALC_PROC_NAME)
    00096
    00097         #if LH_DATA_IN_SIZE_16
    00098         inputOffset = (long)calcParam->cmInputPixelOffset / 2;
    00099         #else
    00100         inputOffset = (long)calcParam->cmInputPixelOffset;
    00101         #endif
    00102         #if LH_DATA_OUT_SIZE_16
    00103         outputOffset = (long)calcParam->cmOutputPixelOffset / 2;
    00104         #else
    00105         outputOffset = (long)calcParam->cmOutputPixelOffset;
    00106         #endif
    00107
    00108         if (calcParam->clearMask)
    00109                 Mask = 0;
    00110         Mode = LH_CALC_ENGINE_UNDEF_MODE;
    00111
    00112
    00113         if ((calcParam->cmInputPixelOffset * calcParam->cmPixelPerLine == calcParam->cmInputBytesPerLine) && (calcParam->cmOutputPixelOffset * calcParam->cmPixelPerLine == calcParam->cmOutputBytesPerLine))
    00114         {
    00115                 PixelCount = calcParam->cmPixelPerLine * calcParam->cmLineCount;
    00116                 LineCount = 1;
    00117         }
    00118         else
    00119         {
    00120                 PixelCount = calcParam->cmPixelPerLine;
    00121                 LineCount = calcParam->cmLineCount;
    00122         }
    00123         if (calcParam->copyAlpha )
    00124         {
    00125                         Mode = LH_CALC_ENGINE_U_TO_U;
    00126         }
    00127         else
    00128         {
    00129                 if (calcParam->clearMask)
    00130                         Mode = LH_CALC_ENGINE_P_TO_U;
    00131                 else
    00132                         Mode = LH_CALC_ENGINE_P_TO_P;
    00133         }
    00134         j = 0;
    00135         while (LineCount)
    00136         {
    00137                 i = PixelCount;
    00138                 while (i)
    00139                 {
    00140                         #if LH_LUT_DATA_SIZE_16
    00141                         #if LH_DATA_IN_SIZE_16 || LH_DATA_OUT_SIZE_16
    00142                         register LH_UINT32 ko;
    00143                         #endif
    00144                         #if LH_DATA_IN_SIZE_16
    00145                         register LH_DATA_IN_TYPE aValIn;
    00146                 #endif
    00147                         #if LH_DATA_OUT_SIZE_16
    00148                         register LH_UINT32 aVal;
    00149                 #endif
    00150                         #if LH_DATA_IN_SIZE_16
    00151                                 aValIn = (ein_cache=*input0) - ( *input0 >> ( LH_ADR_BREIT_EIN_LUT ));
    00152                                 ko = aValIn & ( (1<<( 16-LH_ADR_BREIT_EIN_LUT ))-1 );
    00153                                 aValIn = (aValIn >> ( 16-LH_ADR_BREIT_EIN_LUT )) + ( 0 << LH_ADR_BREIT_EIN_LUT );
    00154                         ein_regr = ( My_InputLut[aValIn] * ( (1<<( 16-LH_ADR_BREIT_EIN_LUT )) - ko ) + My_InputLut[aValIn +1] * ko ) >>( 16-LH_ADR_BREIT_EIN_LUT );
    00155                         #else
    00156                         ein_regr = My_InputLut[(ein_cache=*input0) + ( 0 << LH_ADR_BREIT_EIN_LUT )];
    00157                         #endif
    00158                         #else
    00159                         #if LH_DATA_IN_SIZE_16
    00160                         register LH_DATA_IN_TYPE aValIn;
    00161                         register LH_UINT32 ko;
    00162                                 aValIn = (ein_cache=*input0) - ( *input0 >> ( LH_ADR_BREIT_EIN_LUT ));
    00163                                 ko = aValIn & ( (1<<( 16-LH_ADR_BREIT_EIN_LUT ))-1 );
    00164                                 aValIn = (aValIn >> ( 16-LH_ADR_BREIT_EIN_LUT )) + ( 0 << LH_ADR_BREIT_EIN_LUT );
    00165                         ein_regr = ( My_InputLut[aValIn] * ( (1<<( 16-LH_ADR_BREIT_EIN_LUT )) - ko ) + My_InputLut[aValIn +1] * ko ) >>( 10-LH_ADR_BREIT_EIN_LUT );
    00166                         #else
    00167                         ein_regr = My_InputLut[(ein_cache=*input0) + ( 0 << LH_ADR_BREIT_EIN_LUT )];
    00168                         #endif
    00169                         #endif
    00170                         paNewVal0 = (LH_LUT_DATA_TYPE *)My_ColorLut +
    00171                                                 ((ein_regr >> LH_BIT_BREIT_SELEKTOR)*LH_DATA_OUT_COUNT);
    00172                         ein_regr &= LH_BIT_MASKE_SELEKTOR;
    00173
    00174                         ako0 = (LH_ADR_BEREICH_SEL) - ein_regr;
    00175                         #if LH_LUT_DATA_SIZE_16
    00176                         #if LH_DATA_OUT_SIZE_16
    00177
    00178                         aVal =                                   (ako0          * paNewVal0[0] +
    00179                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT]);
    00180                         aVal = aVal + ( aVal >> ( LH_LUT_DATA_SHR ));
    00181                         aVal = aVal - ( aVal >> ( LH_ADR_BREIT_AUS_LUT ));
    00182                         ko = (aVal>>LH_DATA_SHR_CORR) & ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR))-1 );
    00183                         aVal = (aVal >> ( LH_DATA_SHR )) + ( 0 << LH_ADR_BREIT_AUS_LUT );
    00184                         *output0 = (LH_DATA_OUT_TYPE)((My_OutputLut[aVal] * ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR )) - ko ) + My_OutputLut[aVal +1] * ko)>>(LH_DATA_SHR - LH_DATA_SHR_CORR) );
    00185
    00186                         if( LH_DATA_OUT_COUNT > 1 ){
    00187                         paNewVal0++;
    00188                         aVal =                                   (ako0          * paNewVal0[0] +
    00189                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT]);
    00190                         aVal = aVal + ( aVal >> ( LH_LUT_DATA_SHR ));
    00191                         aVal = aVal - ( aVal >> ( LH_ADR_BREIT_AUS_LUT ));
    00192                         ko = (aVal>>LH_DATA_SHR_CORR) & ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR))-1 );
    00193                         aVal = (aVal >> ( LH_DATA_SHR )) + ( 1 << LH_ADR_BREIT_AUS_LUT );
    00194                         *output1 = (LH_DATA_OUT_TYPE)((My_OutputLut[aVal] * ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR )) - ko ) + My_OutputLut[aVal +1] * ko)>>(LH_DATA_SHR - LH_DATA_SHR_CORR) );
    00195
    00196                         paNewVal0++;
    00197                         aVal =                                   (ako0          * paNewVal0[0] +
    00198                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT]);
    00199                         aVal = aVal + ( aVal >> ( LH_LUT_DATA_SHR ));
    00200                         aVal = aVal - ( aVal >> ( LH_ADR_BREIT_AUS_LUT ));
    00201                         ko = (aVal>>LH_DATA_SHR_CORR) & ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR))-1 );
    00202                         aVal = (aVal >> ( LH_DATA_SHR )) + ( 2 << LH_ADR_BREIT_AUS_LUT );
    00203                         *output2 = (LH_DATA_OUT_TYPE)((My_OutputLut[aVal] * ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR )) - ko ) + My_OutputLut[aVal +1] * ko)>>(LH_DATA_SHR - LH_DATA_SHR_CORR) );
    00204
    00205                         if( LH_DATA_OUT_COUNT > 3 ){
    00206                         paNewVal0++;
    00207                         aVal =                                   (ako0          * paNewVal0[0] +
    00208                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT]);
    00209                         aVal = aVal + ( aVal >> ( LH_LUT_DATA_SHR ));
    00210                         aVal = aVal - ( aVal >> ( LH_ADR_BREIT_AUS_LUT ));
    00211                         ko = (aVal>>LH_DATA_SHR_CORR) & ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR))-1 );
    00212                         aVal = (aVal >> ( LH_DATA_SHR )) + ( 3 << LH_ADR_BREIT_AUS_LUT );
    00213                         *output3 = (LH_DATA_OUT_TYPE)((My_OutputLut[aVal] * ( (1<<( LH_DATA_SHR - LH_DATA_SHR_CORR )) - ko ) + My_OutputLut[aVal +1] * ko)>>(LH_DATA_SHR - LH_DATA_SHR_CORR) );
    00214                         }}
    00215
    00216                         #else
    00217                         *output0 = My_OutputLut[((ako0          * paNewVal0[0] +
    00218                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (0<<LH_ADR_BREIT_AUS_LUT)]>>8;
    00219                         if( LH_DATA_OUT_COUNT > 1 ){
    00220                         paNewVal0++;
    00221                         *output1 = My_OutputLut[((ako0          * paNewVal0[0] +
    00222                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (1<<LH_ADR_BREIT_AUS_LUT)]>>8;
    00223                         paNewVal0++;
    00224                         *output2 = My_OutputLut[((ako0          * paNewVal0[0] +
    00225                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (2<<LH_ADR_BREIT_AUS_LUT)]>>8;
    00226                         if( LH_DATA_OUT_COUNT > 3 ){
    00227                         paNewVal0++;
    00228                         *output3 = My_OutputLut[((ako0          * paNewVal0[0] +
    00229                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (3<<LH_ADR_BREIT_AUS_LUT)]>>8;
    00230                         }}
    00231                         #endif
    00232
    00233                         #else
    00234                         *output0 = My_OutputLut[((ako0          * paNewVal0[0] +
    00235                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (0<<LH_ADR_BREIT_AUS_LUT)];
    00236                         if( LH_DATA_OUT_COUNT > 1 ){
    00237                         paNewVal0++;
    00238                         *output1 = My_OutputLut[((ako0          * paNewVal0[0] +
    00239                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (1<<LH_ADR_BREIT_AUS_LUT)];
    00240                         paNewVal0++;
    00241                         *output2 = My_OutputLut[((ako0          * paNewVal0[0] +
    00242                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (2<<LH_ADR_BREIT_AUS_LUT)];
    00243                         if( LH_DATA_OUT_COUNT > 3 ){
    00244                         paNewVal0++;
    00245                         *output3 = My_OutputLut[((ako0          * paNewVal0[0] +
    00246                                                                           ein_regr      * paNewVal0[LH_DATA_OUT_COUNT])>>LH_DATA_SHR) + (3<<LH_ADR_BREIT_AUS_LUT)];
    00247                         }}
    00248                         #endif
    00249
    00250                         #if LH_DATA_OUT_SIZE_16 && ! LH_LUT_DATA_SIZE_16
    00251                         *output0 |= (*output0 << 8);
    00252                         if( LH_DATA_OUT_COUNT > 1 ){
    00253                         *output1 |= (*output1 << 8);
    00254                         *output2 |= (*output2 << 8);
    00255                         if( LH_DATA_OUT_COUNT > 3 ){
    00256                         *output3 |= (*output3 << 8);
    00257                         }}
    00258                         #endif
    00259
    00260                         if (Mode == LH_CALC_ENGINE_P_TO_P)
    00261                         {
    00262                                 while (--i)
    00263                                 {
    00264                                         input0 += inputOffset;
    00265                                         output0 += outputOffset;
    00266                                         output1 += outputOffset;
    00267                                         output2 += outputOffset;
    00268                                         output3 += outputOffset;
    00269
    00270                                         if ((*input0 ^ ein_cache)){
    00271                                                 break;
    00272                                         }
    00273                                         *output0 = output0[-outputOffset];
    00274                                         if( LH_DATA_OUT_COUNT > 1 ){
    00275                                         *output1 = output1[-outputOffset];
    00276                                         *output2 = output2[-outputOffset];
    00277                                         if( LH_DATA_OUT_COUNT > 3 ){
    00278                                         *output3 = output3[-outputOffset];
    00279                                         }}
    00280                                 }
    00281                         }
    00282                         else if (Mode == LH_CALC_ENGINE_P_TO_U)
    00283                         {
    00284                                 if( LH_DATA_OUT_COUNT == 1 ){
    00285                                         *output1 &= Mask;
    00286                                 }else if( LH_DATA_OUT_COUNT == 3 ){
    00287                                         *output3 &= Mask;
    00288                                 }else{
    00289                                         *output4 &= Mask;
    00290                                 }
    00291                                 while (--i)
    00292                                 {
    00293                                         input0 += inputOffset;
    00294                                         output0 += outputOffset;
    00295                                         output1 += outputOffset;
    00296                                         output2 += outputOffset;
    00297                                         output3 += outputOffset;
    00298                                         output4 += outputOffset;
    00299                                         if ((*input0 ^ ein_cache)){
    00300                                                 break;
    00301                                         }
    00302                                         *output0 = output0[-outputOffset];
    00303                                         if( LH_DATA_OUT_COUNT > 1 ){
    00304                                                 *output1 = output1[-outputOffset];
    00305                                                 *output2 = output2[-outputOffset];
    00306                                                 if( LH_DATA_OUT_COUNT > 3 ){
    00307                                                         *output3 = output3[-outputOffset];
    00308                                                         *output4 &= Mask;
    00309                                                 }
    00310                                                 else{
    00311                                                         *output3 &= Mask;
    00312                                                 }
    00313                                         }
    00314                                         else{
    00315                                                 *output1 &= Mask;
    00316                                         }
    00317                                 }
    00318                         }
    00319                         else
    00320                         {
    00321                                 if( LH_DATA_OUT_COUNT == 1 ){
    00322                                         *output1 = (LH_DATA_OUT_TYPE)*input1;
    00323                                 }else if( LH_DATA_OUT_COUNT == 3 ){
    00324                                         *output3 = (LH_DATA_OUT_TYPE)*input1;
    00325                                 }else{
    00326                                         *output4 = (LH_DATA_OUT_TYPE)*input1;
    00327                                 }
    00328                                 while (--i)
    00329                                 {                                                               /*U_TO_U*/
    00330                                         input0 += inputOffset;
    00331                                         input1 += inputOffset;
    00332                                         output0 += outputOffset;
    00333                                         output1 += outputOffset;
    00334                                         output2 += outputOffset;
    00335                                         output3 += outputOffset;
    00336                                         output4 += outputOffset;
    00337                                         if ((*input0 ^ ein_cache))
    00338                                         {
    00339                                                 break;
    00340                                         }
    00341                                         *output0 = output0[-outputOffset];
    00342                                         if( LH_DATA_OUT_COUNT > 1 ){
    00343                                                 *output1 = output1[-outputOffset];
    00344                                                 *output2 = output2[-outputOffset];
    00345                                                 if( LH_DATA_OUT_COUNT > 3 ){
    00346                                                         *output3 = output3[-outputOffset];
    00347                                                         *output4 = (LH_DATA_OUT_TYPE)*input1;
    00348                                                 }
    00349                                                 else{
    00350                                                         *output3 = (LH_DATA_OUT_TYPE)*input1;
    00351                                                 }
    00352                                         }
    00353                                         else{
    00354                                                 *output1 = (LH_DATA_OUT_TYPE)*input1;
    00355                                         }
    00356                                 }
    00357                         }
    00358                 }
    00359                 if (--LineCount)
    00360                 {
    00361                         j++;
    00362                         input0 = (LH_DATA_IN_TYPE *)((LH_UINT8 *)calcParam->inputData[0] + j * calcParam->cmInputBytesPerLine);
    00363                         input1 = (LH_DATA_IN_TYPE *)((LH_UINT8 *)calcParam->inputData[1] + j * calcParam->cmInputBytesPerLine);
    00364
    00365                         output0 = (LH_DATA_OUT_TYPE *)((LH_UINT8 *)calcParam->outputData[0] + j * calcParam->cmOutputBytesPerLine);
    00366                         output1 = (LH_DATA_OUT_TYPE *)((LH_UINT8 *)calcParam->outputData[1] + j * calcParam->cmOutputBytesPerLine);
    00367                         output2 = (LH_DATA_OUT_TYPE *)((LH_UINT8 *)calcParam->outputData[2] + j * calcParam->cmOutputBytesPerLine);
    00368                         output3 = (LH_DATA_OUT_TYPE *)((LH_UINT8 *)calcParam->outputData[3] + j * calcParam->cmOutputBytesPerLine);
    00369                         output4 = (LH_DATA_OUT_TYPE *)((LH_UINT8 *)calcParam->outputData[4] + j * calcParam->cmOutputBytesPerLine);
    00370                 }
    00371         }
    00372         LH_END_PROC(LH_CALC_PROC_NAME)
    00373         return 0;
    00374 }
    00375 #undef LH_CALC_PROC_NAME