< prev index next >

src/java.desktop/share/native/liblcms/cmsopt.c

Print this page
*** 210,10 ***
--- 210,11 ---
                for (j = 0; j < 3; j++)
                       if (!CloseEnoughFloat(a->v[i].n[j], Identity.v[i].n[j])) return FALSE;
  
         return TRUE;
  }
+ 
  // if two adjacent matrices are found, multiply them.
  static
  cmsBool _MultiplyMatrix(cmsPipeline* Lut)
  {
         cmsStage** pt1;

*** 1140,18 ***
          // Evaluate the gray value
          cmsPipelineEvalFloat(In, Out, OriginalLut);
  
          // Store result in curve
          for (t=0; t < OriginalLut ->InputChannels; t++)
!             Trans[t] ->Table16[i] = _cmsQuickSaturateWord(Out[t] * 65535.0);
      }
  
      // Slope-limit the obtained curves
      for (t = 0; t < OriginalLut ->InputChannels; t++)
          SlopeLimiting(Trans[t]);
  
!     // Check for validity
      lIsSuitable = TRUE;
      lIsLinear   = TRUE;
      for (t=0; (lIsSuitable && (t < OriginalLut ->InputChannels)); t++) {
  
          // Exclude if already linear
--- 1141,21 ---
          // Evaluate the gray value
          cmsPipelineEvalFloat(In, Out, OriginalLut);
  
          // Store result in curve
          for (t=0; t < OriginalLut ->InputChannels; t++)
!         {
+             if (Trans[t]->Table16 != NULL)
+                 Trans[t] ->Table16[i] = _cmsQuickSaturateWord(Out[t] * 65535.0);
+         }
      }
  
      // Slope-limit the obtained curves
      for (t = 0; t < OriginalLut ->InputChannels; t++)
          SlopeLimiting(Trans[t]);
  
!     // Check for validity. lIsLinear is here for debug purposes
      lIsSuitable = TRUE;
      lIsLinear   = TRUE;
      for (t=0; (lIsSuitable && (t < OriginalLut ->InputChannels)); t++) {
  
          // Exclude if already linear

*** 1751,10 ***
--- 1755,12 ---
                       cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
                       &Curve1, &Matrix1, &Curve2)) {
  
                       _cmsStageMatrixData* Data = (_cmsStageMatrixData*)cmsStageData(Matrix1);
  
+                      if (Matrix1->InputChannels != 3 || Matrix1->OutputChannels != 3) return FALSE;
+ 
                       // Copy the matrix to our result
                       memcpy(&res, Data->Double, sizeof(res));
  
                       // Preserve the Odffset (may be NULL as a zero offset)
                       Offset = Data->Offset;

*** 1795,11 ***
      else {
          _cmsStageToneCurvesData* mpeC1 = (_cmsStageToneCurvesData*) cmsStageData(Curve1);
          _cmsStageToneCurvesData* mpeC2 = (_cmsStageToneCurvesData*) cmsStageData(Curve2);
  
          // In this particular optimization, cache does not help as it takes more time to deal with
!         // the cache that with the pixel handling
          *dwFlags |= cmsFLAGS_NOCACHE;
  
          // Setup the optimizarion routines
          SetMatShaper(Dest, mpeC1 ->TheCurves, &res, (cmsVEC3*) Offset, mpeC2->TheCurves, OutputFormat);
      }
--- 1801,11 ---
      else {
          _cmsStageToneCurvesData* mpeC1 = (_cmsStageToneCurvesData*) cmsStageData(Curve1);
          _cmsStageToneCurvesData* mpeC2 = (_cmsStageToneCurvesData*) cmsStageData(Curve2);
  
          // In this particular optimization, cache does not help as it takes more time to deal with
!         // the cache than with the pixel handling
          *dwFlags |= cmsFLAGS_NOCACHE;
  
          // Setup the optimizarion routines
          SetMatShaper(Dest, mpeC1 ->TheCurves, &res, (cmsVEC3*) Offset, mpeC2->TheCurves, OutputFormat);
      }

*** 1952,11 ***
  
      // Named color pipelines cannot be optimized
      for (mpe = cmsPipelineGetPtrToFirstStage(*PtrLut);
          mpe != NULL;
          mpe = cmsStageNext(mpe)) {
!         if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE;
      }
  
      // Try to get rid of identities and trivial conversions.
      AnySuccess = PreOptimize(*PtrLut);
  
--- 1958,11 ---
  
      // Named color pipelines cannot be optimized
      for (mpe = cmsPipelineGetPtrToFirstStage(*PtrLut);
          mpe != NULL;
          mpe = cmsStageNext(mpe)) {
!             if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE;
      }
  
      // Try to get rid of identities and trivial conversions.
      AnySuccess = PreOptimize(*PtrLut);
  
< prev index next >