diff options
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r-- | core/src/fxcodec/codec/codec_int.h | 15 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_icc.cpp | 29 |
2 files changed, 24 insertions, 20 deletions
diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index ae6af007f6..d172d7157e 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -9,11 +9,15 @@ #include <limits.h> #include <list> +#include <map> #include "../../../../third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. #include "../../../include/fxcodec/fx_codec.h" #include "../jbig2/JBig2_Context.h" +class CFX_IccProfileCache; +class CFX_IccTransformCache; + class CCodec_BasicModule : public ICodec_BasicModule { public: virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, @@ -289,18 +293,19 @@ class CCodec_IccModule : public ICodec_IccModule { virtual ~CCodec_IccModule(); protected: - CFX_MapByteStringToPtr m_MapTranform; - CFX_MapByteStringToPtr m_MapProfile; - FX_DWORD m_nComponents; - typedef enum { + enum Icc_CLASS { Icc_CLASS_INPUT = 0, Icc_CLASS_OUTPUT, Icc_CLASS_PROOF, Icc_CLASS_MAX - } Icc_CLASS; + }; void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, Icc_CLASS ic, CFX_BinaryBuf* pTransformKey); + + FX_DWORD m_nComponents; + std::map<CFX_ByteString, CFX_IccTransformCache*> m_MapTranform; + std::map<CFX_ByteString, CFX_IccProfileCache*> m_MapProfile; }; class CCodec_JpxModule : public ICodec_JpxModule { diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp index dad880a936..2a8ccc364c 100644 --- a/core/src/fxcodec/codec/fx_codec_icc.cpp +++ b/core/src/fxcodec/codec/fx_codec_icc.cpp @@ -434,7 +434,8 @@ void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, CFX_ByteString ProfileKey(key.GetBuffer(), key.GetSize()); ASSERT(pTransformKey); pTransformKey->AppendBlock(ProfileKey.GetBuffer(0), ProfileKey.GetLength()); - if (!m_MapProfile.Lookup(ProfileKey, (void*&)pCache)) { + auto it = m_MapProfile.find(ProfileKey); + if (it == m_MapProfile.end()) { pCache = new CFX_IccProfileCache; switch (pIccParam->dwProfileType) { case Icc_PARAMTYPE_BUFFER: @@ -456,8 +457,9 @@ void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, default: break; } - m_MapProfile.SetAt(ProfileKey, pCache); + m_MapProfile[ProfileKey] = pCache; } else { + pCache = it->second; pCache->m_dwRate++; } return pCache->m_pProfile; @@ -496,7 +498,8 @@ void* CCodec_IccModule::CreateTransform( << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag; CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize()); CFX_IccTransformCache* pTransformCache; - if (!m_MapTranform.Lookup(TransformKey, (void*&)pTransformCache)) { + auto it = m_MapTranform.find(TransformKey); + if (it == m_MapTranform.end()) { pCmm = FX_Alloc(CLcmsCmm, 1); pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType); pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType); @@ -512,26 +515,22 @@ void* CCodec_IccModule::CreateTransform( dwOutputProfileType, dwIntent, dwFlag); } pCmm->m_hTransform = pTransformCache->m_pIccTransform; - m_MapTranform.SetAt(TransformKey, pTransformCache); + m_MapTranform[TransformKey] = pTransformCache; } else { + pTransformCache = it->second; pTransformCache->m_dwRate++; } return pTransformCache->m_pCmm; } CCodec_IccModule::~CCodec_IccModule() { - FX_POSITION pos = m_MapProfile.GetStartPosition(); - CFX_ByteString key; - CFX_IccProfileCache* pProfileCache; - while (pos) { - m_MapProfile.GetNextAssoc(pos, key, (void*&)pProfileCache); - delete pProfileCache; + for (const auto& pair : m_MapProfile) { + delete pair.second; } - pos = m_MapTranform.GetStartPosition(); - CFX_IccTransformCache* pTransformCache; - while (pos) { - m_MapTranform.GetNextAssoc(pos, key, (void*&)pTransformCache); - delete pTransformCache; + m_MapProfile.clear(); + for (const auto& pair : m_MapTranform) { + delete pair.second; } + m_MapTranform.clear(); } void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData, FX_DWORD dwProfileSize, |