summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-07-08 15:30:46 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-07-08 15:30:46 -0700
commit3522876d5291922ddc62bf1b70d02743b0850673 (patch)
treeb3fd7eda6e8ed8f07674f6a6fba21e82ca83bee7 /core/src/fxcodec
parente7ee98e4c6fd56c9e930194e9fc11cc10e8293a1 (diff)
downloadpdfium-3522876d5291922ddc62bf1b70d02743b0850673.tar.xz
Remove custom memory manager
BUG= R=palmer@chromium.org Review URL: https://codereview.chromium.org/372473003
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp6
-rw-r--r--core/src/fxcodec/codec/fx_codec_fax.cpp39
-rw-r--r--core/src/fxcodec/codec/fx_codec_flate.cpp1
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp1
-rw-r--r--core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.c13
-rw-r--r--core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c40
-rw-r--r--core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_malloc.h12
-rw-r--r--core/src/fxcodec/lcms2/lcms2-2.6/src/cmserr.c8
8 files changed, 48 insertions, 72 deletions
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index c6b3ccee43..456ec40fea 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../include/fxcodec/fx_codec.h"
@@ -119,8 +119,7 @@ void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height)
FX_Free(m_pDataCache);
m_pDataCache = NULL;
}
- m_pDataCache = (CCodec_ImageDataCache*)FXMEM_DefaultAlloc(
- sizeof(CCodec_ImageDataCache) + m_Pitch * m_OutputHeight, FXMEM_NONLEAVE);
+ m_pDataCache = (CCodec_ImageDataCache*)FX_AllocNL(FX_BYTE, sizeof(CCodec_ImageDataCache) + m_Pitch * m_OutputHeight);
if (m_pDataCache == NULL) {
return;
}
@@ -337,7 +336,6 @@ FX_BOOL CCodec_RLScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size,
if (m_pScanline == NULL) {
return FALSE;
}
- FXSYS_memset32(m_pScanline, 0, m_Pitch);
return CheckDestSize();
}
FX_BOOL CCodec_RLScanlineDecoder::v_Rewind()
diff --git a/core/src/fxcodec/codec/fx_codec_fax.cpp b/core/src/fxcodec/codec/fx_codec_fax.cpp
index 979df38197..c6c13f98bb 100644
--- a/core/src/fxcodec/codec/fx_codec_fax.cpp
+++ b/core/src/fxcodec/codec/fx_codec_fax.cpp
@@ -6,8 +6,43 @@
#include "../../../include/fxcodec/fx_codec.h"
#include "codec_int.h"
-extern const FX_BYTE OneLeadPos[256];
-extern const FX_BYTE ZeroLeadPos[256];
+const FX_BYTE OneLeadPos[256] = {
+ 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8,
+};
+
int _FindBit(const FX_BYTE* data_buf, int max_pos, int start_pos, int bit)
{
if (start_pos >= max_pos) {
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index 4724593a94..c02f0977cf 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -654,7 +654,6 @@ FX_BOOL CCodec_FlateScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_siz
if (m_pLastLine == NULL) {
return FALSE;
}
- FXSYS_memset32(m_pLastLine, 0, m_PredictPitch);
m_pPredictRaw = FX_Alloc(FX_BYTE, m_PredictPitch + 1);
if (m_pPredictRaw == NULL) {
return FALSE;
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index aae3e24c05..37399f8eb8 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -196,7 +196,6 @@ static void _JpegEncode(const CFX_DIBSource* pSource, FX_LPBYTE& dest_buf, FX_ST
dest_buf_length >>= 1;
dest_buf = FX_Alloc(FX_BYTE, dest_buf_length);
}
- FXSYS_memset32(dest_buf, 0, dest_buf_length);
struct jpeg_destination_mgr dest;
dest.init_destination = _dest_do_nothing;
dest.term_destination = _dest_do_nothing;
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.c b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.c
index 5f710e87b2..60698e3ffe 100644
--- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.c
+++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/dwt.c
@@ -140,9 +140,7 @@ static void opj_v4dwt_interleave_h(opj_v4dwt_t* restrict w, OPJ_FLOAT32* restric
static void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a , OPJ_INT32 x, OPJ_INT32 nb_elts_read);
-//#ifdef __SSE__
-// Disable __SSE__ due to bug http://crbug.com/373619. Should enable this after adding aligned malloc in memory manager
-#if 0
+#ifdef __SSE__
static void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c);
static void opj_v4dwt_decode_step2_sse(opj_v4_t* l, opj_v4_t* w, OPJ_INT32 k, OPJ_INT32 m, __m128 c);
@@ -673,9 +671,8 @@ void opj_v4dwt_interleave_v(opj_v4dwt_t* restrict v , OPJ_FLOAT32* restrict a ,
}
}
-//#ifdef __SSE__
-// Disable __SSE__ due to bug http://crbug.com/373619. Should enable this after adding aligned malloc in memory manager
-#if 0
+#ifdef __SSE__
+
void opj_v4dwt_decode_step1_sse(opj_v4_t* w, OPJ_INT32 count, const __m128 c){
__m128* restrict vw = (__m128*) w;
OPJ_INT32 i;
@@ -812,9 +809,7 @@ void opj_v4dwt_decode(opj_v4dwt_t* restrict dwt)
b = 0;
}
-//#ifdef __SSE__
-// Disable __SSE__ due to bug http://crbug.com/373619. Should enable this after adding aligned malloc in memory manager
-#if 0
+#ifdef __SSE__
opj_v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(opj_K));
opj_v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(opj_c13318));
opj_v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, opj_int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(opj_dwt_delta));
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c
index 77a864ebb9..bf411efca5 100644
--- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c
+++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c
@@ -10253,43 +10253,3 @@ OPJ_BOOL opj_j2k_write_tile (opj_j2k_t * p_j2k,
return OPJ_TRUE;
}
-
-#ifdef _FOXIT_MEM_MANAGER_
-/** Allocate number of bytes */
-void* FXMEM_DefaultAlloc(int byte_size, int flags);
-void* FXMEM_DefaultRealloc(void* pointer, int new_size, int flags);
-void FXMEM_DefaultFree(void* pointer, int flags);
-
-void* opj_malloc(size_t size)
-{
- if (size >= (size_t)-0x100 || (int)size < 0) return NULL;
-
- return FXMEM_DefaultAlloc(size, 0);
-}
-
-void* opj_calloc(size_t _NumOfElements, size_t _SizeOfElements)
-{
- void* buffer = NULL;
-
- if (_NumOfElements != 0 && _NumOfElements >= (size_t)-0x100 / _SizeOfElements) return NULL;
- if ((int)_NumOfElements < 0 || (int)_SizeOfElements < 0) return NULL;
-
- buffer = FXMEM_DefaultAlloc(_NumOfElements * _SizeOfElements, 0);
- if (!buffer) return 0;
-
- memset(buffer, 0, _NumOfElements * _SizeOfElements);
- return buffer;
-}
-
-void* opj_realloc(void * m, size_t s)
-{
- if (s >= (size_t)-0x100 || (int)s < 0) return NULL;
- return FXMEM_DefaultRealloc(m, s, 0);
-}
-
-void opj_free(void * m)
-{
- FXMEM_DefaultFree(m, 0);
-}
-
-#endif
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_malloc.h b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_malloc.h
index ed1dfaf983..f2fe82f1a3 100644
--- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_malloc.h
+++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/opj_malloc.h
@@ -50,16 +50,7 @@ Allocate an uninitialized memory block
@param size Bytes to allocate
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
-#define _FOXIT_MEM_MANAGER_
-#ifdef _FOXIT_MEM_MANAGER_
-void* opj_malloc(size_t size);
-void* opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
-void* opj_realloc(void * m, size_t s);
-void opj_free(void * m);
-
-#define opj_aligned_malloc(size) opj_malloc(size)
-#define opj_aligned_free(m) opj_free(m)
-#else
+
#ifdef ALLOC_PERF_OPT
void * OPJ_CALLCONV opj_malloc(size_t size);
#else
@@ -170,7 +161,6 @@ void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
#else
#define opj_realloc(m, s) realloc(m, s)
#endif
-#endif
/**
Deallocates or frees a memory block.
diff --git a/core/src/fxcodec/lcms2/lcms2-2.6/src/cmserr.c b/core/src/fxcodec/lcms2/lcms2-2.6/src/cmserr.c
index 87c6320cff..964182ae38 100644
--- a/core/src/fxcodec/lcms2/lcms2-2.6/src/cmserr.c
+++ b/core/src/fxcodec/lcms2/lcms2-2.6/src/cmserr.c
@@ -262,13 +262,13 @@ cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugi
// Generic allocate
void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
{
- return FXMEM_DefaultAlloc(size, FXMEM_NONLEAVE);
+ return FXMEM_DefaultAlloc(size, 1);
}
// Generic allocate & zero
void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size)
{
- void* p = FXMEM_DefaultAlloc(size, FXMEM_NONLEAVE);
+ void* p = FXMEM_DefaultAlloc(size, 1);
if (p) FXSYS_memset32(p, 0, size);
return p;
}
@@ -286,7 +286,7 @@ void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32N
// Generic reallocate
void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
{
- return FXMEM_DefaultRealloc(Ptr, size, FXMEM_NONLEAVE);
+ return FXMEM_DefaultRealloc(Ptr, size, 1);
}
// Generic free memory
@@ -298,7 +298,7 @@ void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr)
// Generic block duplication
void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size)
{
- void* p = FXMEM_DefaultAlloc(size, FXMEM_NONLEAVE);
+ void* p = FXMEM_DefaultAlloc(size, 1);
FXSYS_memmove32(p, Org, size);
return p;
}