summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-08-25 11:52:41 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-08-25 11:52:41 -0700
commita550e4cfd41d6e86b2a676e38200f3f4cebf5f2e (patch)
treea81b38c5cf8a1848ea6c5a67e38a0e4b8798b800 /core/src/fxcodec
parentbe831032f3ef4654e0f645785c6a59b1d06a9ad8 (diff)
downloadpdfium-a550e4cfd41d6e86b2a676e38200f3f4cebf5f2e.tar.xz
Revert of Use number of components from ICC profile and alternateCS (patchset #1 of https://codereview.chromium.org/493163003/)
Reason for revert: Needs to address comments before landing Original issue's description: > Use number of components from ICC profile and alternate color space > > BUG=406806 > > Committed: https://pdfium.googlesource.com/pdfium/+/be83103 TBR=tsepez@chromium.org,jun_fang@foxitsoftware.com NOTREECHECKS=true NOTRY=true BUG=406806 Review URL: https://codereview.chromium.org/504883003
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/codec_int.h6
-rw-r--r--core/src/fxcodec/codec/fx_codec_icc.cpp57
2 files changed, 20 insertions, 43 deletions
diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h
index 1b97036e3d..47f2c8e1fe 100644
--- a/core/src/fxcodec/codec/codec_int.h
+++ b/core/src/fxcodec/codec/codec_int.h
@@ -162,10 +162,10 @@ public:
FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING
);
- virtual FX_LPVOID CreateTransform_sRGB(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize, FX_INT32* nComponents, FX_INT32 intent = 0,
+ virtual FX_LPVOID CreateTransform_sRGB(FX_LPCBYTE pProfileData, unsigned int dwProfileSize, int nComponents, int intent = 0,
FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT);
- virtual FX_LPVOID CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32* nSrcComponents,
- FX_LPCBYTE pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 intent = 0,
+ virtual FX_LPVOID CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, unsigned int dwSrcProfileSize, int nSrcComponents,
+ FX_LPCBYTE pDstProfileData, unsigned int dwDstProfileSize, int intent = 0,
FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT,
FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT
);
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index f0ece07c31..b10d9c4868 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -7,12 +7,6 @@
#include "../../../include/fxcodec/fx_codec.h"
#include "codec_int.h"
#include "../lcms2/include/fx_lcms2.h"
-#define N_COMPONENT_LAB 3
-#define N_COMPONENT_GRAY 1
-#define N_COMPONENT_RGB 3
-#define N_COMPONENT_CMYK 4
-#define N_COMPONENT_DEFAULT 3
-
FX_BOOL MD5ComputeID( FX_LPCVOID buf, FX_DWORD dwSize, FX_BYTE ID[16] )
{
return cmsMD5computeIDExt(buf, dwSize, ID);
@@ -65,35 +59,14 @@ FX_BOOL CheckComponents(cmsColorSpaceSignature cs, int nComponents, FX_BOOL bDst
}
return TRUE;
}
-FX_INT32 GetCSComponents(cmsColorSpaceSignature cs)
-{
- switch (cs) {
- case cmsSigLabData:
- return N_COMPONENT_LAB;
- break;
- case cmsSigGrayData:
- return N_COMPONENT_GRAY;
- break;
- case cmsSigRgbData:
- return N_COMPONENT_RGB;
- break;
- case cmsSigCmykData:
- return N_COMPONENT_CMYK;
- break;
- default:
- return N_COMPONENT_DEFAULT;
- break;
- }
-}
-void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32* nSrcComponents,
- const unsigned char* pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 nDstComponents,
+void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, unsigned int dwSrcProfileSize, int nSrcComponents,
+ const unsigned char* pDstProfileData, unsigned int dwDstProfileSize, int nDstComponents,
int intent, FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT)
{
cmsHPROFILE srcProfile = NULL;
cmsHPROFILE dstProfile = NULL;
cmsHTRANSFORM hTransform = NULL;
CLcmsCmm* pCmm = NULL;
- *nSrcComponents = 0;
srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize);
if (srcProfile == NULL) {
return NULL;
@@ -110,12 +83,16 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSr
int srcFormat;
FX_BOOL bLab = FALSE;
cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile);
- *nSrcComponents = GetCSComponents(srcCS);
+ if (!CheckComponents(srcCS, nSrcComponents, FALSE)) {
+ cmsCloseProfile(srcProfile);
+ cmsCloseProfile(dstProfile);
+ return NULL;
+ }
if (srcCS == cmsSigLabData) {
- srcFormat = COLORSPACE_SH(PT_Lab) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(0);
+ srcFormat = COLORSPACE_SH(PT_Lab) | CHANNELS_SH(nSrcComponents) | BYTES_SH(0);
bLab = TRUE;
} else {
- srcFormat = COLORSPACE_SH(PT_ANY) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(1);
+ srcFormat = COLORSPACE_SH(PT_ANY) | CHANNELS_SH(nSrcComponents) | BYTES_SH(1);
if (srcCS == cmsSigRgbData && T_DOSWAP(dwSrcFormat)) {
srcFormat |= DOSWAP_SH(1);
}
@@ -150,7 +127,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSr
if (pCmm == NULL) {
return NULL;
}
- pCmm->m_nSrcComponents = *nSrcComponents;
+ pCmm->m_nSrcComponents = nSrcComponents;
pCmm->m_nDstComponents = nDstComponents;
pCmm->m_hTransform = hTransform;
pCmm->m_bLab = bLab;
@@ -158,7 +135,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, FX_DWORD dwSr
cmsCloseProfile(dstProfile);
return pCmm;
}
-void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, FX_DWORD dwProfileSize, FX_INT32* nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat)
+void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, unsigned int dwProfileSize, int nComponents, int intent, FX_DWORD dwSrcFormat)
{
return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, 0, 3, intent, dwSrcFormat);
}
@@ -215,7 +192,7 @@ void IccLib_Translate(void* pTransform, FX_DWORD nSrcComponents, FX_FLOAT* pSrcV
break;
}
}
-void IccLib_TranslateImage(void* pTransform, unsigned char* pDest, const unsigned char* pSrc, FX_INT32 pixels)
+void IccLib_TranslateImage(void* pTransform, unsigned char* pDest, const unsigned char* pSrc, int pixels)
{
cmsDoTransform(((CLcmsCmm*)pTransform)->m_hTransform, (void*)pSrc, pDest, pixels);
}
@@ -265,7 +242,7 @@ ICodec_IccModule::IccCS GetProfileCSFromHandle(FX_LPVOID pProfile)
return ICodec_IccModule::IccCS_Unknown;
}
}
-ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize)
+ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(FX_LPCBYTE pProfileData, unsigned int dwProfileSize)
{
ICodec_IccModule::IccCS cs;
cmsHPROFILE hProfile = cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
@@ -540,12 +517,12 @@ CCodec_IccModule::~CCodec_IccModule()
}
}
}
-void* CCodec_IccModule::CreateTransform_sRGB(FX_LPCBYTE pProfileData, FX_DWORD dwProfileSize, FX_INT32* nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat)
+void* CCodec_IccModule::CreateTransform_sRGB(FX_LPCBYTE pProfileData, unsigned int dwProfileSize, int nComponents, int intent, FX_DWORD dwSrcFormat)
{
return IccLib_CreateTransform_sRGB(pProfileData, dwProfileSize, nComponents, intent, dwSrcFormat);
}
-void* CCodec_IccModule::CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, FX_DWORD dwSrcProfileSize, FX_INT32* nSrcComponents,
- FX_LPCBYTE pDstProfileData, FX_DWORD dwDstProfileSize, FX_INT32 intent,
+void* CCodec_IccModule::CreateTransform_CMYK(FX_LPCBYTE pSrcProfileData, unsigned int dwSrcProfileSize, int nSrcComponents,
+ FX_LPCBYTE pDstProfileData, unsigned int dwDstProfileSize, int intent,
FX_DWORD dwSrcFormat , FX_DWORD dwDstFormat)
{
return IccLib_CreateTransform(pSrcProfileData, dwSrcProfileSize, nSrcComponents,
@@ -559,7 +536,7 @@ void CCodec_IccModule::Translate(void* pTransform, FX_FLOAT* pSrcValues, FX_FLOA
{
IccLib_Translate(pTransform, m_nComponents, pSrcValues, pDestValues);
}
-void CCodec_IccModule::TranslateScanline(void* pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, FX_INT32 pixels)
+void CCodec_IccModule::TranslateScanline(void* pTransform, FX_LPBYTE pDest, FX_LPCBYTE pSrc, int pixels)
{
IccLib_TranslateImage(pTransform, pDest, pSrc, pixels);
}