diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc index 0bafb6d..ef72ffc 100644 --- a/poppler/GfxState.cc +++ b/poppler/GfxState.cc @@ -1649,7 +1649,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, int recu obj1.free(); #ifdef USE_CMS // check cache - if (out && iccProfileStreamA.num > 0) { + if (out && iccProfileStreamA.num > 0) { GfxICCBasedColorSpaceKey k(iccProfileStreamA.num, iccProfileStreamA.gen); GfxICCBasedColorSpaceItem *item = static_cast(out->getIccColorSpaceCache()->lookup(k)); if (item != NULL) @@ -5301,6 +5301,14 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, } } break; +#ifdef USE_CMS + case csICCBased: + if (nComps == 3) { + lookup2[3] = (GfxColorComp *) gmalloc_checkoverflow(67108864); + if (lookup2[3] != NULL) + memset(lookup2[3], -1, 67108864); + } +#endif default: if (colorSpace->useGetGrayLine() || colorSpace->useGetRGBLine()) { byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps); @@ -5415,10 +5423,29 @@ void GfxImageColorMap::getRGB(Guchar *x, GfxRGB *rgb) { } colorSpace2->getRGB(&color, rgb); } else { +#ifdef USE_CMS + if (colorSpace->getMode() == csICCBased && nComps == 3 && lookup2[3] != NULL) { + unsigned int offset = ((((x[0] << 8) + x[1]) << 8) + x[2]) << 2; + unsigned int cachedVal = *((unsigned int *) ((Guchar *)lookup2[3] + offset)); + if ( cachedVal != 0xffffffff) { + rgb->r = byteToCol((cachedVal >> 16) & 0xff); + rgb->g = byteToCol((cachedVal >> 8) & 0xff); + rgb->b = byteToCol(cachedVal & 0xff); + return; + } + } +#endif for (i = 0; i < nComps; ++i) { color.c[i] = lookup2[i][x[i]]; } colorSpace->getRGB(&color, rgb); +#ifdef USE_CMS + if (colorSpace->getMode() == csICCBased && nComps == 3 && lookup2[3] != NULL) { + unsigned int offset = ((((x[0] << 8) + x[1]) << 8) + x[2]) << 2; + unsigned int cachedVal = (colToByte(rgb->r) << 16) + (colToByte(rgb->g) << 8) + colToByte(rgb->b); + *((unsigned int *) ((Guchar *)lookup2[3] + offset)) = cachedVal; + } +#endif } }