summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-07 10:46:22 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-07 10:46:23 -0700
commit4997b22f84307521a62838f874928bf56cd3423c (patch)
treead11d99ac0a491ee222e9d0a42ec3b6ad3354e2a /core/fxcodec
parent0687e76dc259c678b3f29a6608331f07ffd8f1e2 (diff)
downloadpdfium-4997b22f84307521a62838f874928bf56cd3423c.tar.xz
Get rid of NULLs in core/
Review-Url: https://codereview.chromium.org/2032613003
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/fx_codec.cpp6
-rw-r--r--core/fxcodec/codec/fx_codec_bmp.cpp4
-rw-r--r--core/fxcodec/codec/fx_codec_fax.cpp2
-rw-r--r--core/fxcodec/codec/fx_codec_flate.cpp15
-rw-r--r--core/fxcodec/codec/fx_codec_gif.cpp4
-rw-r--r--core/fxcodec/codec/fx_codec_icc.cpp56
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp6
-rw-r--r--core/fxcodec/codec/fx_codec_jpeg.cpp7
-rw-r--r--core/fxcodec/codec/fx_codec_jpx_opj.cpp20
-rw-r--r--core/fxcodec/codec/fx_codec_png.cpp22
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp221
-rw-r--r--core/fxcodec/codec/fx_codec_tiff.cpp32
-rw-r--r--core/fxcodec/codec/include/ccodec_progressivedecoder.h6
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp20
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.h2
-rw-r--r--core/fxcodec/jbig2/JBig2_Image.cpp33
-rw-r--r--core/fxcodec/jbig2/JBig2_PatternDict.cpp2
-rw-r--r--core/fxcodec/jbig2/JBig2_Segment.cpp4
-rw-r--r--core/fxcodec/lbmp/fx_bmp.cpp117
-rw-r--r--core/fxcodec/lbmp/fx_bmp.h2
-rw-r--r--core/fxcodec/lgif/fx_gif.cpp214
-rw-r--r--core/fxcodec/lgif/fx_gif.h4
22 files changed, 382 insertions, 417 deletions
diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp
index 6a45737b10..55cb6ee7fb 100644
--- a/core/fxcodec/codec/fx_codec.cpp
+++ b/core/fxcodec/codec/fx_codec.cpp
@@ -127,8 +127,8 @@ class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder {
uint8_t m_Operator;
};
CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder()
- : m_pScanline(NULL),
- m_pSrcBuf(NULL),
+ : m_pScanline(nullptr),
+ m_pSrcBuf(nullptr),
m_SrcSize(0),
m_dwLineBytes(0),
m_SrcOffset(0),
@@ -206,7 +206,7 @@ uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() {
GetNextOperator();
} else {
if (m_bEOD) {
- return NULL;
+ return nullptr;
}
}
FXSYS_memset(m_pScanline, 0, m_Pitch);
diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/fx_codec_bmp.cpp
index 03390cfea3..beda53c05b 100644
--- a/core/fxcodec/codec/fx_codec_bmp.cpp
+++ b/core/fxcodec/codec/fx_codec_bmp.cpp
@@ -113,8 +113,8 @@ int32_t CCodec_BmpModule::LoadImage(FXBMP_Context* ctx) {
}
uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx,
- uint8_t** avial_buf_ptr) {
- return bmp_get_avail_input(ctx->bmp_ptr, avial_buf_ptr);
+ uint8_t** avail_buf_ptr) {
+ return bmp_get_avail_input(ctx->bmp_ptr, avail_buf_ptr);
}
void CCodec_BmpModule::Input(FXBMP_Context* ctx,
diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp
index 90d3b24cab..c0202829ee 100644
--- a/core/fxcodec/codec/fx_codec_fax.cpp
+++ b/core/fxcodec/codec/fx_codec_fax.cpp
@@ -537,7 +537,7 @@ uint8_t* CCodec_FaxDecoder::v_GetNextLine() {
int bitsize = m_SrcSize * 8;
FaxSkipEOL(m_pSrcBuf, bitsize, bitpos);
if (bitpos >= bitsize) {
- return NULL;
+ return nullptr;
}
FXSYS_memset(m_pScanlineBuf, 0xff, m_Pitch);
if (m_Encoding < 0) {
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index cd24b6624c..d32a8a13ba 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -648,11 +648,11 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder {
};
CCodec_FlateScanlineDecoder::CCodec_FlateScanlineDecoder() {
- m_pFlate = NULL;
- m_pScanline = NULL;
- m_pLastLine = NULL;
- m_pPredictBuffer = NULL;
- m_pPredictRaw = NULL;
+ m_pFlate = nullptr;
+ m_pScanline = nullptr;
+ m_pLastLine = nullptr;
+ m_pPredictBuffer = nullptr;
+ m_pPredictRaw = nullptr;
m_LeftOver = 0;
}
CCodec_FlateScanlineDecoder::~CCodec_FlateScanlineDecoder() {
@@ -799,7 +799,7 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW,
uint32_t estimated_size,
uint8_t*& dest_buf,
uint32_t& dest_size) {
- dest_buf = NULL;
+ dest_buf = nullptr;
uint32_t offset = 0;
int predictor_type = 0;
if (predictor) {
@@ -814,7 +814,8 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW,
std::unique_ptr<CLZWDecoder> decoder(new CLZWDecoder);
dest_size = (uint32_t)-1;
offset = src_size;
- int err = decoder->Decode(NULL, dest_size, src_buf, offset, bEarlyChange);
+ int err =
+ decoder->Decode(nullptr, dest_size, src_buf, offset, bEarlyChange);
if (err || dest_size == 0 || dest_size + 1 < dest_size) {
return FX_INVALID_OFFSET;
}
diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp
index 13576412c2..f04192ebef 100644
--- a/core/fxcodec/codec/fx_codec_gif.cpp
+++ b/core/fxcodec/codec/fx_codec_gif.cpp
@@ -175,8 +175,8 @@ int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx,
}
uint32_t CCodec_GifModule::GetAvailInput(FXGIF_Context* ctx,
- uint8_t** avial_buf_ptr) {
- return gif_get_avail_input(ctx->gif_ptr, avial_buf_ptr);
+ uint8_t** avail_buf_ptr) {
+ return gif_get_avail_input(ctx->gif_ptr, avail_buf_ptr);
}
void CCodec_GifModule::Input(FXGIF_Context* ctx,
diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp
index 876297fd40..4903c24715 100644
--- a/core/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/fxcodec/codec/fx_codec_icc.cpp
@@ -98,15 +98,13 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
int intent,
uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
uint32_t 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) {
- return NULL;
- }
+ cmsHPROFILE srcProfile =
+ cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize);
+ if (!srcProfile)
+ return nullptr;
+
+ cmsHPROFILE dstProfile;
if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) {
dstProfile = cmsCreate_sRGBProfile();
} else {
@@ -115,7 +113,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
}
if (!dstProfile) {
cmsCloseProfile(srcProfile);
- return NULL;
+ return nullptr;
}
int srcFormat;
FX_BOOL bLab = FALSE;
@@ -136,8 +134,10 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
if (!CheckComponents(dstCS, nDstComponents, TRUE)) {
cmsCloseProfile(srcProfile);
cmsCloseProfile(dstProfile);
- return NULL;
+ return nullptr;
}
+
+ cmsHTRANSFORM hTransform = nullptr;
switch (dstCS) {
case cmsSigGrayData:
hTransform = cmsCreateTransform(srcProfile, srcFormat, dstProfile,
@@ -158,9 +158,9 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
if (!hTransform) {
cmsCloseProfile(srcProfile);
cmsCloseProfile(dstProfile);
- return NULL;
+ return nullptr;
}
- pCmm = new CLcmsCmm;
+ CLcmsCmm* pCmm = new CLcmsCmm;
pCmm->m_nSrcComponents = nSrcComponents;
pCmm->m_nDstComponents = nDstComponents;
pCmm->m_hTransform = hTransform;
@@ -174,8 +174,8 @@ void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData,
uint32_t& nComponents,
int32_t intent,
uint32_t dwSrcFormat) {
- return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL,
- 0, 3, intent, dwSrcFormat);
+ return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents,
+ nullptr, 0, 3, intent, dwSrcFormat);
}
void IccLib_DestroyTransform(void* pTransform) {
if (!pTransform) {
@@ -241,11 +241,11 @@ void IccLib_TranslateImage(void* pTransform,
void* CreateProfile_Gray(double gamma) {
cmsCIExyY* D50 = (cmsCIExyY*)cmsD50_xyY();
if (!cmsWhitePointFromTemp(D50, 6504)) {
- return NULL;
+ return nullptr;
}
- cmsToneCurve* curve = cmsBuildGamma(NULL, gamma);
+ cmsToneCurve* curve = cmsBuildGamma(nullptr, gamma);
if (!curve) {
- return NULL;
+ return nullptr;
}
void* profile = cmsCreateGrayProfile(D50, curve);
cmsFreeToneCurve(curve);
@@ -365,7 +365,7 @@ class CFX_IccProfileCache {
void Purge();
};
CFX_IccProfileCache::CFX_IccProfileCache() {
- m_pProfile = NULL;
+ m_pProfile = nullptr;
m_dwRate = 1;
}
CFX_IccProfileCache::~CFX_IccProfileCache() {
@@ -376,7 +376,7 @@ CFX_IccProfileCache::~CFX_IccProfileCache() {
void CFX_IccProfileCache::Purge() {}
class CFX_IccTransformCache {
public:
- CFX_IccTransformCache(CLcmsCmm* pCmm = NULL);
+ CFX_IccTransformCache(CLcmsCmm* pCmm = nullptr);
~CFX_IccTransformCache();
void* m_pIccTransform;
uint32_t m_dwRate;
@@ -386,7 +386,7 @@ class CFX_IccTransformCache {
void Purge();
};
CFX_IccTransformCache::CFX_IccTransformCache(CLcmsCmm* pCmm) {
- m_pIccTransform = NULL;
+ m_pIccTransform = nullptr;
m_dwRate = 1;
m_pCmm = pCmm;
}
@@ -409,14 +409,14 @@ CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) {
void* CCodec_IccModule::CreateProfile(CCodec_IccModule::IccParam* pIccParam,
Icc_CLASS ic,
CFX_BinaryBuf* pTransformKey) {
- CFX_IccProfileCache* pCache = NULL;
+ CFX_IccProfileCache* pCache = nullptr;
CFX_ByteStringKey key;
CFX_ByteString text;
key << pIccParam->ColorSpace << (pIccParam->dwProfileType | ic << 8);
uint8_t ID[16];
switch (pIccParam->dwProfileType) {
case Icc_PARAMTYPE_NONE:
- return NULL;
+ return nullptr;
case Icc_PARAMTYPE_BUFFER:
MD5ComputeID(pIccParam->pProfileData, pIccParam->dwProfileSize, ID);
break;
@@ -476,30 +476,30 @@ void* CCodec_IccModule::CreateTransform(
uint32_t dwFlag,
uint32_t dwPrfIntent,
uint32_t dwPrfFlag) {
- CLcmsCmm* pCmm = NULL;
+ CLcmsCmm* pCmm = nullptr;
ASSERT(pInputParam && pOutputParam);
CFX_ByteStringKey key;
void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key);
if (!pInputProfile) {
- return NULL;
+ return nullptr;
}
void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key);
if (!pOutputProfile) {
- return NULL;
+ return nullptr;
}
uint32_t dwInputProfileType =
TransferProfileType(pInputProfile, pInputParam->dwFormat);
uint32_t dwOutputProfileType =
TransferProfileType(pOutputProfile, pOutputParam->dwFormat);
if (dwInputProfileType == 0 || dwOutputProfileType == 0) {
- return NULL;
+ return nullptr;
}
- void* pProofProfile = NULL;
+ void* pProofProfile = nullptr;
if (pProofParam) {
pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key);
}
key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag
- << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag;
+ << !!pProofProfile << dwPrfIntent << dwPrfFlag;
CFX_ByteString TransformKey(key.GetBuffer(), key.GetSize());
CFX_IccTransformCache* pTransformCache;
auto it = m_MapTranform.find(TransformKey);
diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp
index 2b0be1070e..30798fe361 100644
--- a/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -68,7 +68,7 @@ void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) {
((CCodec_Jbig2Context*)pJbig2Content)->m_pContext);
delete (CCodec_Jbig2Context*)pJbig2Content;
}
- pJbig2Content = NULL;
+ pJbig2Content = nullptr;
}
FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
void* pJbig2Context,
@@ -105,7 +105,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
if (m_pJbig2Context->m_pContext->GetProcessingStatus() ==
FXCODEC_STATUS_DECODE_FINISH) {
CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
- m_pJbig2Context->m_pContext = NULL;
+ m_pJbig2Context->m_pContext = nullptr;
if (ret != JBIG2_SUCCESS) {
return FXCODEC_STATUS_ERROR;
}
@@ -127,7 +127,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context,
return m_pJbig2Context->m_pContext->GetProcessingStatus();
}
CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
- m_pJbig2Context->m_pContext = NULL;
+ m_pJbig2Context->m_pContext = nullptr;
if (ret != JBIG2_SUCCESS) {
return FXCODEC_STATUS_ERROR;
}
diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp
index cbfea59329..c2814a4b4c 100644
--- a/core/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/fxcodec/codec/fx_codec_jpeg.cpp
@@ -78,11 +78,10 @@ static void _error_do_nothing2(j_common_ptr cinfo, char*) {}
#define JPEG_MARKER_ICC (JPEG_APP0 + 2)
#define JPEG_MARKER_MAXSIZE 0xFFFF
-
#ifdef PDF_ENABLE_XFA
static void JpegLoadAttribute(struct jpeg_decompress_struct* pInfo,
CFX_DIBAttribute* pAttribute) {
- if (!pInfo || !pAttribute)
+ if (!pAttribute)
return;
pAttribute->m_nXDPI = pInfo->X_density;
@@ -178,7 +177,7 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder {
};
CCodec_JpegDecoder::CCodec_JpegDecoder() {
- m_pScanlineBuf = NULL;
+ m_pScanlineBuf = nullptr;
m_bStarted = FALSE;
m_bInited = FALSE;
FXSYS_memset(&cinfo, 0, sizeof(cinfo));
@@ -470,7 +469,7 @@ FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx,
uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx,
uint8_t** avail_buf_ptr) {
if (avail_buf_ptr) {
- *avail_buf_ptr = NULL;
+ *avail_buf_ptr = nullptr;
if (ctx->m_SrcMgr.bytes_in_buffer > 0) {
*avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte;
}
diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp
index a0f2e65c75..9e72c509d7 100644
--- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -122,13 +122,13 @@ opj_stream_t* fx_opj_stream_create_memory_stream(DecodeData* data,
OPJ_BOOL p_is_read_stream) {
opj_stream_t* l_stream = 00;
if (!data || !data->src_data || data->src_size <= 0) {
- return NULL;
+ return nullptr;
}
l_stream = opj_stream_create(p_size, p_is_read_stream);
if (!l_stream) {
- return NULL;
+ return nullptr;
}
- opj_stream_set_user_data(l_stream, data, NULL);
+ opj_stream_set_user_data(l_stream, data, nullptr);
opj_stream_set_user_data_length(l_stream, data->src_size);
opj_stream_set_read_function(l_stream, opj_read_from_memory);
opj_stream_set_write_function(l_stream, opj_write_from_memory);
@@ -611,7 +611,7 @@ void color_apply_conversion(opj_image_t* image) {
cmsHTRANSFORM transform;
cmsUInt16Number RGB[3];
cmsCIELab Lab;
- in = cmsCreateLab4Profile(NULL);
+ in = cmsCreateLab4Profile(nullptr);
out = cmsCreate_sRGBProfile();
transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16,
INTENT_PERCEPTUAL, 0);
@@ -718,7 +718,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) {
if (!src_data || src_size < sizeof(szJP2Header))
return FALSE;
- image = NULL;
+ image = nullptr;
m_SrcData = src_data;
m_SrcSize = src_size;
DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
@@ -749,7 +749,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) {
return FALSE;
}
if (!opj_read_header(l_stream, l_codec, &image)) {
- image = NULL;
+ image = nullptr;
return FALSE;
}
image->pdfium_use_colorspace = !!m_ColorSpace;
@@ -758,13 +758,13 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) {
if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0,
parameters.DA_x1, parameters.DA_y1)) {
opj_image_destroy(image);
- image = NULL;
+ image = nullptr;
return FALSE;
}
if (!(opj_decode(l_codec, l_stream, image) &&
opj_end_decompress(l_codec, l_stream))) {
opj_image_destroy(image);
- image = NULL;
+ image = nullptr;
return FALSE;
}
} else {
@@ -774,7 +774,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) {
}
}
opj_stream_destroy(l_stream);
- l_stream = NULL;
+ l_stream = nullptr;
if (image->color_space != OPJ_CLRSPC_SYCC && image->numcomps == 3 &&
image->comps[0].dx == image->comps[0].dy && image->comps[1].dx != 1) {
image->color_space = OPJ_CLRSPC_SYCC;
@@ -786,7 +786,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) {
}
if (image->icc_profile_buf) {
FX_Free(image->icc_profile_buf);
- image->icc_profile_buf = NULL;
+ image->icc_profile_buf = nullptr;
image->icc_profile_len = 0;
}
if (!image) {
diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp
index f7b922973e..9f7faa68e0 100644
--- a/core/fxcodec/codec/fx_codec_png.cpp
+++ b/core/fxcodec/codec/fx_codec_png.cpp
@@ -51,7 +51,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr,
#endif
int bTime = 0;
#if defined(PNG_tIME_SUPPORTED)
- png_timep t = NULL;
+ png_timep t = nullptr;
png_get_tIME(png_ptr, info_ptr, &t);
if (t) {
FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));
@@ -67,7 +67,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr,
FX_STRSIZE len;
const FX_CHAR* buf;
int num_text;
- png_textp text = NULL;
+ png_textp text = nullptr;
png_get_text(png_ptr, info_ptr, &text, &num_text);
for (i = 0; i < num_text; i++) {
len = FXSYS_strlen(text[i].key);
@@ -110,18 +110,18 @@ static void _png_free_func(void* p) {
};
static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) {
FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr);
- if (p == NULL) {
+ if (!p)
return;
- }
+
CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr;
- if (pModule == NULL) {
+ if (!pModule)
return;
- }
+
png_uint_32 width = 0, height = 0;
int bpc = 0, color_type = 0, color_type1 = 0, pass = 0;
double gamma = 1.0;
- png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, NULL,
- NULL, NULL);
+ png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, nullptr,
+ nullptr, nullptr);
color_type1 = color_type;
if (bpc > 8) {
png_set_strip_16(png_ptr);
@@ -182,11 +182,11 @@ static void _png_get_row_func(png_structp png_ptr,
png_uint_32 row_num,
int pass) {
FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr);
- if (p == NULL) {
+ if (!p)
return;
- }
+
CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr;
- uint8_t* src_buf = NULL;
+ uint8_t* src_buf = nullptr;
if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) {
png_error(png_ptr, "Ask Scanline buffer Callback Error");
}
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 95a90b3e68..ec3347cdaa 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -39,9 +39,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len,
sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + 1));
m_DestMin = dest_min;
m_pWeightTables = FX_Alloc(uint8_t, (dest_max - dest_min) * m_ItemSize + 4);
- if (m_pWeightTables == NULL) {
- return;
- }
if (FXSYS_fabs((FX_FLOAT)scale) < 1.0f) {
for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel++) {
PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel);
@@ -131,9 +128,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len,
m_ItemSize = sizeof(int) * 4;
int size = dest_len * m_ItemSize + 4;
m_pWeightTables = FX_Alloc(uint8_t, size);
- if (m_pWeightTables == NULL) {
- return;
- }
FXSYS_memset(m_pWeightTables, 0, size);
if (scale > 1) {
int pre_des_col = 0;
@@ -192,9 +186,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
m_ItemSize = sizeof(int) * 4;
int size = dest_len * m_ItemSize + 4;
m_pWeightTables = FX_Alloc(uint8_t, size);
- if (m_pWeightTables == NULL) {
- return;
- }
FXSYS_memset(m_pWeightTables, 0, size);
if (scale > 1) {
double step = 0.0;
@@ -247,17 +238,17 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
}
CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder(
CCodec_ModuleMgr* pCodecMgr) {
- m_pFile = NULL;
- m_pJpegContext = NULL;
- m_pPngContext = NULL;
- m_pGifContext = NULL;
- m_pBmpContext = NULL;
- m_pTiffContext = NULL;
- m_pCodecMgr = NULL;
- m_pSrcBuf = NULL;
- m_pDecodeBuf = NULL;
- m_pDeviceBitmap = NULL;
- m_pSrcPalette = NULL;
+ m_pFile = nullptr;
+ m_pJpegContext = nullptr;
+ m_pPngContext = nullptr;
+ m_pGifContext = nullptr;
+ m_pBmpContext = nullptr;
+ m_pTiffContext = nullptr;
+ m_pCodecMgr = nullptr;
+ m_pSrcBuf = nullptr;
+ m_pDecodeBuf = nullptr;
+ m_pDeviceBitmap = nullptr;
+ m_pSrcPalette = nullptr;
m_pCodecMgr = pCodecMgr;
m_offSet = 0;
m_SrcSize = 0;
@@ -278,13 +269,13 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder(
m_SrcPaletteNumber = 0;
m_GifPltNumber = 0;
m_GifBgIndex = 0;
- m_pGifPalette = NULL;
+ m_pGifPalette = nullptr;
m_GifTransIndex = -1;
m_GifFrameRect = FX_RECT(0, 0, 0, 0);
m_BmpIsTopBottom = FALSE;
}
CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
- m_pFile = NULL;
+ m_pFile = nullptr;
if (m_pJpegContext) {
m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext);
}
@@ -312,7 +303,7 @@ FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData(
return FALSE;
}
dwSize = dwSize - m_offSet;
- uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, NULL);
+ uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, nullptr);
if (dwAvail == m_SrcSize) {
if (dwSize > FXCODEC_BLOCK_SIZE) {
dwSize = FXCODEC_BLOCK_SIZE;
@@ -349,7 +340,7 @@ FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule,
int* color_type,
double* gamma) {
CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule;
- if (pCodec->m_pDeviceBitmap == NULL) {
+ if (!pCodec->m_pDeviceBitmap) {
pCodec->m_SrcWidth = width;
pCodec->m_SrcHeight = height;
pCodec->m_SrcBPC = bpc;
@@ -570,7 +561,7 @@ FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule,
return FALSE;
}
dwSize = dwSize - m_offSet;
- uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, NULL);
+ uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, nullptr);
if (dwAvail == m_SrcSize) {
if (dwSize > FXCODEC_BLOCK_SIZE) {
dwSize = FXCODEC_BLOCK_SIZE;
@@ -631,21 +622,21 @@ FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback(
error_status)) {
return FALSE;
}
- uint8_t* pPalette = NULL;
+ uint8_t* pPalette = nullptr;
if (pal_num != 0 && pal_ptr) {
pPalette = (uint8_t*)pal_ptr;
} else {
pal_num = pCodec->m_GifPltNumber;
pPalette = pCodec->m_pGifPalette;
}
- if (pCodec->m_pSrcPalette == NULL) {
+ if (!pCodec->m_pSrcPalette) {
pCodec->m_pSrcPalette = FX_Alloc(FX_ARGB, pal_num);
} else if (pal_num > pCodec->m_SrcPaletteNumber) {
pCodec->m_pSrcPalette = FX_Realloc(FX_ARGB, pCodec->m_pSrcPalette, pal_num);
}
- if (pCodec->m_pSrcPalette == NULL) {
+ if (!pCodec->m_pSrcPalette)
return FALSE;
- }
+
pCodec->m_SrcPaletteNumber = pal_num;
for (int i = 0; i < pal_num; i++) {
uint32_t j = i * 3;
@@ -852,7 +843,7 @@ FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule,
return FALSE;
}
dwSize = dwSize - m_offSet;
- uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, NULL);
+ uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, nullptr);
if (dwAvail == m_SrcSize) {
if (dwSize > FXCODEC_BLOCK_SIZE) {
dwSize = FXCODEC_BLOCK_SIZE;
@@ -1020,7 +1011,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
switch (imageType) {
case FXCODEC_IMAGE_BMP: {
CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
- if (pBmpModule == NULL) {
+ if (!pBmpModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1028,7 +1019,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
BmpInputImagePositionBufCallback;
pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback;
m_pBmpContext = pBmpModule->Start((void*)this);
- if (m_pBmpContext == NULL) {
+ if (!m_pBmpContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1039,7 +1030,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
}
m_offSet += size;
pBmpModule->Input(m_pBmpContext, m_pSrcBuf, size);
- uint32_t* pPalette = NULL;
+ uint32_t* pPalette = nullptr;
int32_t readResult = pBmpModule->ReadHeader(
m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
&m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute);
@@ -1068,19 +1059,19 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
}
if (m_pBmpContext) {
pBmpModule->Finish(m_pBmpContext);
- m_pBmpContext = NULL;
+ m_pBmpContext = nullptr;
}
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
} break;
case FXCODEC_IMAGE_JPG: {
CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule();
- if (pJpegModule == NULL) {
+ if (!pJpegModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
m_pJpegContext = pJpegModule->Start();
- if (m_pJpegContext == NULL) {
+ if (!m_pJpegContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1111,14 +1102,14 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
}
if (m_pJpegContext) {
pJpegModule->Finish(m_pJpegContext);
- m_pJpegContext = NULL;
+ m_pJpegContext = nullptr;
}
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
} break;
case FXCODEC_IMAGE_PNG: {
CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
- if (pPngModule == NULL) {
+ if (!pPngModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1129,7 +1120,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
pPngModule->FillScanlineBufCompletedCallback =
CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc;
m_pPngContext = pPngModule->Start((void*)this);
- if (m_pPngContext == NULL) {
+ if (!m_pPngContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1148,7 +1139,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
}
- m_pPngContext = NULL;
+ m_pPngContext = nullptr;
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
}
@@ -1170,7 +1161,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
ASSERT(!bResult);
if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
- m_pPngContext = NULL;
+ m_pPngContext = nullptr;
}
if (m_SrcPassNumber == 0) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
@@ -1179,7 +1170,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
} break;
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
- if (pGifModule == NULL) {
+ if (!pGifModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1192,7 +1183,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
pGifModule->ReadScanlineCallback =
CCodec_ProgressiveDecoder::GifReadScanlineCallback;
m_pGifContext = pGifModule->Start((void*)this);
- if (m_pGifContext == NULL) {
+ if (!m_pGifContext) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return FALSE;
}
@@ -1224,19 +1215,19 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
}
if (m_pGifContext) {
pGifModule->Finish(m_pGifContext);
- m_pGifContext = NULL;
+ m_pGifContext = nullptr;
}
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
} break;
case FXCODEC_IMAGE_TIF: {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
- if (pTiffModule == NULL) {
+ if (!pTiffModule) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
}
m_pTiffContext = pTiffModule->CreateDecoder(m_pFile);
- if (m_pTiffContext == NULL) {
+ if (!m_pTiffContext) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return FALSE;
}
@@ -1250,7 +1241,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType(
m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
if (!ret) {
pTiffModule->DestroyDecoder(m_pTiffContext);
- (m_pTiffContext = NULL);
+ (m_pTiffContext = nullptr);
(m_status = FXCODEC_STATUS_ERR_FORMAT);
return FALSE;
}
@@ -1274,9 +1265,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo(
default:
break;
}
- if (pFile == NULL) {
+ if (!pFile) {
m_status = FXCODEC_STATUS_ERR_PARAMS;
- m_pFile = NULL;
+ m_pFile = nullptr;
return m_status;
}
m_pFile = pFile;
@@ -1301,7 +1292,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo(
}
}
m_status = FXCODEC_STATUS_ERR_FORMAT;
- m_pFile = NULL;
+ m_pFile = nullptr;
return m_status;
}
void CCodec_ProgressiveDecoder::SetClipBox(FX_RECT* clip) {
@@ -1830,7 +1821,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames,
}
if (m_pGifContext) {
pGifModule->Finish(m_pGifContext);
- m_pGifContext = NULL;
+ m_pGifContext = nullptr;
}
return m_status = FXCODEC_STATUS_ERROR;
}
@@ -1847,10 +1838,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
int size_y,
int32_t frames,
FX_BOOL bInterpol) {
- if (m_status != FXCODEC_STATUS_DECODE_READY) {
+ if (m_status != FXCODEC_STATUS_DECODE_READY)
return FXCODEC_STATUS_ERROR;
- }
- if (pDIBitmap == NULL || pDIBitmap->GetBPP() < 8 || frames < 0 ||
+
+ if (!pDIBitmap || pDIBitmap->GetBPP() < 8 || frames < 0 ||
frames >= m_FrameNumber) {
return FXCODEC_STATUS_ERR_PARAMS;
}
@@ -1906,8 +1897,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
while (!bStart) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR;
if (!JpegReadMoreData(pJpegModule, error_status)) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = error_status;
}
bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale);
@@ -1936,19 +1927,19 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
} break;
case FXCODEC_IMAGE_PNG: {
CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule();
- if (pPngModule == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ if (!pPngModule) {
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
- m_pPngContext = NULL;
+ m_pPngContext = nullptr;
}
m_pPngContext = pPngModule->Start((void*)this);
- if (m_pPngContext == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ if (!m_pPngContext) {
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
m_offSet = 0;
@@ -1968,8 +1959,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
m_SrcFormat = FXCodec_Argb;
break;
default: {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_PARAMS;
}
}
@@ -1984,9 +1975,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
} break;
case FXCODEC_IMAGE_GIF: {
CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule();
- if (pGifModule == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ if (!pGifModule) {
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
m_SrcFormat = FXCodec_8bppRgb;
@@ -2003,9 +1994,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap,
} break;
case FXCODEC_IMAGE_BMP: {
CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule();
- if (pBmpModule == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ if (!pBmpModule) {
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
switch (m_SrcComponents) {
@@ -2049,8 +2040,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
while (!readRes) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
if (!JpegReadMoreData(pJpegModule, error_status)) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = error_status;
}
readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf);
@@ -2060,8 +2051,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
_RGB2BGR(m_pDecodeBuf + m_clipBox.left * src_Bpp, m_clipBox.Width());
}
if (m_SrcRow >= m_clipBox.bottom) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_DECODE_FINISH;
}
Resample(m_pDeviceBitmap, m_SrcRow, m_pDecodeBuf, m_SrcFormat);
@@ -2081,9 +2072,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
if (m_pPngContext) {
pPngModule->Finish(m_pPngContext);
}
- m_pPngContext = NULL;
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pPngContext = nullptr;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_DECODE_FINISH;
}
if (m_pSrcBuf && input_size > m_SrcSize) {
@@ -2094,16 +2085,16 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
}
FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size);
if (!bResult) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_READ;
}
m_offSet += input_size;
bResult =
pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr);
if (!bResult) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERROR;
}
if (pPause && pPause->NeedToPauseNow()) {
@@ -2119,8 +2110,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
while (readRes == 2) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
if (!GifReadMoreData(pGifModule, error_status)) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = error_status;
}
if (pPause && pPause->NeedToPauseNow()) {
@@ -2129,12 +2120,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr);
}
if (readRes == 1) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_DECODE_FINISH;
}
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERROR;
}
} break;
@@ -2145,8 +2136,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
while (readRes == 2) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
if (!BmpReadMoreData(pBmpModule, error_status)) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = error_status;
}
if (pPause && pPause->NeedToPauseNow()) {
@@ -2155,12 +2146,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
readRes = pBmpModule->LoadImage(m_pBmpContext);
}
if (readRes == 1) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_DECODE_FINISH;
}
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERROR;
}
} break;
@@ -2174,8 +2165,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
m_clipBox.left == 0 && m_clipBox.top == 0 &&
m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) {
ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap);
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
if (!ret) {
return m_status = FXCODEC_STATUS_ERROR;
}
@@ -2183,17 +2174,17 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
} else {
CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap;
pDIBitmap->Create(m_SrcWidth, m_SrcHeight, FXDIB_Argb);
- if (pDIBitmap->GetBuffer() == NULL) {
+ if (!pDIBitmap->GetBuffer()) {
delete pDIBitmap;
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
ret = pTiffModule->Decode(m_pTiffContext, pDIBitmap);
if (!ret) {
delete pDIBitmap;
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERROR;
}
CFX_DIBitmap* pClipBitmap =
@@ -2204,12 +2195,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
if (pDIBitmap != pClipBitmap) {
delete pDIBitmap;
}
- if (pClipBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ if (!pClipBitmap) {
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
- CFX_DIBitmap* pFormatBitmap = NULL;
+ CFX_DIBitmap* pFormatBitmap = nullptr;
switch (m_pDeviceBitmap->GetFormat()) {
case FXDIB_8bppRgb:
pFormatBitmap = new CFX_DIBitmap;
@@ -2279,26 +2270,26 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) {
if (pClipBitmap != pFormatBitmap) {
delete pClipBitmap;
}
- if (pFormatBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ if (!pFormatBitmap) {
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
CFX_DIBitmap* pStrechBitmap = pFormatBitmap->StretchTo(
m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE);
delete pFormatBitmap;
- pFormatBitmap = NULL;
- if (pStrechBitmap == NULL) {
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ pFormatBitmap = nullptr;
+ if (!pStrechBitmap) {
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_ERR_MEMORY;
}
m_pDeviceBitmap->TransferBitmap(m_startX, m_startY, m_sizeX, m_sizeY,
pStrechBitmap, 0, 0);
delete pStrechBitmap;
- pStrechBitmap = NULL;
- m_pDeviceBitmap = NULL;
- m_pFile = NULL;
+ pStrechBitmap = nullptr;
+ m_pDeviceBitmap = nullptr;
+ m_pFile = nullptr;
return m_status = FXCODEC_STATUS_DECODE_FINISH;
}
} break;
diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp
index d4dc139265..c8c94dbcdb 100644
--- a/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/fxcodec/codec/fx_codec_tiff.cpp
@@ -73,15 +73,15 @@ CCodec_TiffContext::CCodec_TiffContext() {
offset = 0;
frame_num = 0;
frame_cur = 0;
- io.in = NULL;
- tif_ctx = NULL;
- icc_ctx = NULL;
+ io.in = nullptr;
+ tif_ctx = nullptr;
+ icc_ctx = nullptr;
isDecoder = TRUE;
}
CCodec_TiffContext::~CCodec_TiffContext() {
if (icc_ctx) {
IccLib_DestroyTransform(icc_ctx);
- icc_ctx = NULL;
+ icc_ctx = nullptr;
}
if (tif_ctx) {
TIFFClose(tif_ctx);
@@ -193,9 +193,9 @@ int TIFFCmyk2Rgb(thandle_t context,
uint8* r,
uint8* g,
uint8* b) {
- if (context == NULL) {
+ if (!context)
return 0;
- }
+
CCodec_TiffContext* p = (CCodec_TiffContext*)context;
if (p->icc_ctx) {
unsigned char cmyk[4], bgr[3];
@@ -209,11 +209,7 @@ int TIFFCmyk2Rgb(thandle_t context,
}
FX_BOOL CCodec_TiffContext::InitDecoder(IFX_FileRead* file_ptr) {
io.in = file_ptr;
- tif_ctx = _tiff_open(this, "r");
- if (tif_ctx == NULL) {
- return FALSE;
- }
- return TRUE;
+ return !!_tiff_open(this, "r");
}
void CCodec_TiffContext::GetFrames(int32_t& frames) {
frames = frame_num = TIFFNumberOfDirectories(tif_ctx);
@@ -231,11 +227,11 @@ void CCodec_TiffContext::GetFrames(int32_t& frames) {
} \
} \
} \
- (key) = NULL;
+ (key) = nullptr;
#define TIFF_EXIF_GETSTRINGINFO(key, tag) \
{ \
uint32_t size = 0; \
- uint8_t* buf = NULL; \
+ uint8_t* buf = nullptr; \
TIFFGetField(tif_ctx, tag, &size, &buf); \
if (size && buf) { \
(key) = FX_Alloc(uint8_t, size); \
@@ -245,7 +241,7 @@ void CCodec_TiffContext::GetFrames(int32_t& frames) {
} \
} \
} \
- (key) = NULL;
+ (key) = nullptr;
namespace {
@@ -287,7 +283,7 @@ FX_BOOL CCodec_TiffContext::LoadFrameInfo(int32_t frame,
}
uint16_t tif_cs;
uint32_t tif_icc_size = 0;
- uint8_t* tif_icc_buf = NULL;
+ uint8_t* tif_icc_buf = nullptr;
uint16_t tif_bpc = 0;
uint16_t tif_cps;
uint32_t tif_rps;
@@ -399,7 +395,7 @@ FX_BOOL CCodec_TiffContext::Decode1bppRGB(CFX_DIBitmap* pDIBitmap,
SetPalette(pDIBitmap, bps);
int32_t size = (int32_t)TIFFScanlineSize(tif_ctx);
uint8_t* buf = (uint8_t*)_TIFFmalloc(size);
- if (buf == NULL) {
+ if (!buf) {
TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer");
return FALSE;
}
@@ -426,7 +422,7 @@ FX_BOOL CCodec_TiffContext::Decode8bppRGB(CFX_DIBitmap* pDIBitmap,
SetPalette(pDIBitmap, bps);
int32_t size = (int32_t)TIFFScanlineSize(tif_ctx);
uint8_t* buf = (uint8_t*)_TIFFmalloc(size);
- if (buf == NULL) {
+ if (!buf) {
TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer");
return FALSE;
}
@@ -459,7 +455,7 @@ FX_BOOL CCodec_TiffContext::Decode24bppRGB(CFX_DIBitmap* pDIBitmap,
}
int32_t size = (int32_t)TIFFScanlineSize(tif_ctx);
uint8_t* buf = (uint8_t*)_TIFFmalloc(size);
- if (buf == NULL) {
+ if (!buf) {
TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer");
return FALSE;
}
diff --git a/core/fxcodec/codec/include/ccodec_progressivedecoder.h b/core/fxcodec/codec/include/ccodec_progressivedecoder.h
index 83b73e1ba7..5421d73494 100644
--- a/core/fxcodec/codec/include/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/include/ccodec_progressivedecoder.h
@@ -73,7 +73,7 @@ class CCodec_ProgressiveDecoder {
class CFXCODEC_WeightTable {
public:
- CFXCODEC_WeightTable() { m_pWeightTables = NULL; }
+ CFXCODEC_WeightTable() { m_pWeightTables = nullptr; }
~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); }
void Calc(int dest_len,
@@ -93,7 +93,7 @@ class CCodec_ProgressiveDecoder {
class CFXCODEC_HorzTable {
public:
- CFXCODEC_HorzTable() { m_pWeightTables = NULL; }
+ CFXCODEC_HorzTable() { m_pWeightTables = nullptr; }
~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); }
void Calc(int dest_len, int src_len, FX_BOOL bInterpol);
@@ -107,7 +107,7 @@ class CCodec_ProgressiveDecoder {
class CFXCODEC_VertTable {
public:
- CFXCODEC_VertTable() { m_pWeightTables = NULL; }
+ CFXCODEC_VertTable() { m_pWeightTables = nullptr; }
~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); }
void Calc(int dest_len, int src_len);
PixelWeight* GetPixelWeight(int pixel) {
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index 25c9ff7649..8dde290be6 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -69,7 +69,7 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
m_PauseStep(10),
m_pPause(pPause),
m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY),
- m_gbContext(NULL),
+ m_gbContext(nullptr),
m_dwOffset(0),
m_pSymbolDictCache(pSymbolDictCache),
m_bIsGlobal(bIsGlobal) {
@@ -85,9 +85,9 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
CJBig2_Context::~CJBig2_Context() {
FX_Free(m_gbContext);
- m_gbContext = NULL;
+ m_gbContext = nullptr;
delete m_pGlobalContext;
- m_pGlobalContext = NULL;
+ m_pGlobalContext = nullptr;
}
int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
@@ -259,7 +259,7 @@ CJBig2_Segment* CJBig2_Context::findReferredSegmentByTypeAndIndex(
++count;
}
}
- return NULL;
+ return nullptr;
}
int32_t CJBig2_Context::parseSegmentHeader(CJBig2_Segment* pSegment) {
if (m_pStream->readInteger(&pSegment->m_dwNumber) != 0 ||
@@ -737,7 +737,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
pTRD->SBSYMS = SBSYMS.get();
} else {
- pTRD->SBSYMS = NULL;
+ pTRD->SBSYMS = nullptr;
}
std::unique_ptr<JBig2HuffmanCode, FxFreeDeleter> SBSYMCODES;
@@ -946,7 +946,7 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im,
(JBig2ComposeOp)(ri.flags & 0x03));
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
return JBIG2_SUCCESS;
}
@@ -1064,7 +1064,7 @@ int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment* pSegment,
m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im,
(JBig2ComposeOp)(ri.flags & 0x03));
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
return JBIG2_SUCCESS;
}
@@ -1137,7 +1137,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
} else {
m_pArithDecoder.reset();
FX_Free(m_gbContext);
- m_gbContext = NULL;
+ m_gbContext = nullptr;
if (!pSegment->m_Result.im) {
m_ProcessingStatus = FXCODEC_STATUS_ERROR;
m_pGRD.reset();
@@ -1168,7 +1168,7 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
pSegment->m_Result.im,
(JBig2ComposeOp)(m_ri.flags & 0x03), &Rect);
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
m_pGRD.reset();
return JBIG2_SUCCESS;
@@ -1238,7 +1238,7 @@ int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment* pSegment) {
m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im,
(JBig2ComposeOp)(ri.flags & 0x03));
delete pSegment->m_Result.im;
- pSegment->m_Result.im = NULL;
+ pSegment->m_Result.im = nullptr;
}
return JBIG2_SUCCESS;
}
diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h
index fa68588a4a..950ad130d7 100644
--- a/core/fxcodec/jbig2/JBig2_Context.h
+++ b/core/fxcodec/jbig2/JBig2_Context.h
@@ -44,7 +44,7 @@ class CJBig2_Context {
CPDF_StreamAcc* pGlobalStream,
CPDF_StreamAcc* pSrcStream,
std::list<CJBig2_CachePair>* pSymbolDictCache,
- IFX_Pause* pPause = NULL);
+ IFX_Pause* pPause = nullptr);
static void DestroyContext(CJBig2_Context* pContext);
diff --git a/core/fxcodec/jbig2/JBig2_Image.cpp b/core/fxcodec/jbig2/JBig2_Image.cpp
index 6a1c060b75..cf0ee3bbbc 100644
--- a/core/fxcodec/jbig2/JBig2_Image.cpp
+++ b/core/fxcodec/jbig2/JBig2_Image.cpp
@@ -14,7 +14,7 @@ CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) {
m_nWidth = w;
m_nHeight = h;
if (m_nWidth <= 0 || m_nHeight <= 0 || m_nWidth > INT_MAX - 31) {
- m_pData = NULL;
+ m_pData = nullptr;
m_bNeedFree = FALSE;
return;
}
@@ -22,7 +22,7 @@ CJBig2_Image::CJBig2_Image(int32_t w, int32_t h) {
if (m_nStride * m_nHeight > 0 && 104857600 / (int)m_nStride > m_nHeight) {
m_pData = FX_Alloc2D(uint8_t, m_nStride, m_nHeight);
} else {
- m_pData = NULL;
+ m_pData = nullptr;
}
m_bNeedFree = TRUE;
}
@@ -44,7 +44,7 @@ CJBig2_Image::CJBig2_Image(const CJBig2_Image& im) {
m_pData = FX_Alloc2D(uint8_t, m_nStride, m_nHeight);
JBIG2_memcpy(m_pData, im.m_pData, m_nStride * m_nHeight);
} else {
- m_pData = NULL;
+ m_pData = nullptr;
}
m_bNeedFree = TRUE;
}
@@ -120,12 +120,12 @@ FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst,
int32_t y,
JBig2ComposeOp op,
const FX_RECT* pSrcRect) {
- if (!m_pData) {
+ if (!m_pData)
return FALSE;
- }
- if (NULL == pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight)) {
+
+ if (!pSrcRect || *pSrcRect == FX_RECT(0, 0, m_nWidth, m_nHeight))
return composeTo_opt2(pDst, x, y, op);
- }
+
return composeTo_opt2(pDst, x, y, op, pSrcRect);
}
@@ -159,7 +159,7 @@ CJBig2_Image* CJBig2_Image::subImage(int32_t x,
uint32_t wTmp;
uint8_t *pSrc, *pSrcEnd, *pDst, *pDstEnd;
if (w == 0 || h == 0) {
- return NULL;
+ return nullptr;
}
CJBig2_Image* pImage = new CJBig2_Image(w, h);
if (!m_pData) {
@@ -243,14 +243,12 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
uint32_t s1 = 0, d1 = 0, d2 = 0, shift = 0, shift1 = 0, shift2 = 0, tmp = 0,
tmp1 = 0, tmp2 = 0, maskL = 0, maskR = 0, maskM = 0;
- uint8_t *lineSrc = NULL, *lineDst = NULL, *sp = NULL, *dp = NULL;
-
- if (!m_pData) {
+ if (!m_pData)
return FALSE;
- }
- if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576) {
+
+ if (x < -1048576 || x > 1048576 || y < -1048576 || y > 1048576)
return FALSE;
- }
+
if (y < 0) {
ys0 = -y;
}
@@ -286,9 +284,9 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
maskL = 0xffffffff >> d1;
maskR = 0xffffffff << ((32 - (xd1 & 31)) % 32);
maskM = maskL & maskR;
- lineSrc = m_pData + ys0 * m_nStride + ((xs0 >> 5) << 2);
+ uint8_t* lineSrc = m_pData + ys0 * m_nStride + ((xs0 >> 5) << 2);
lineLeft = m_nStride - ((xs0 >> 5) << 2);
- lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
+ uint8_t* lineDst = pDst->m_pData + yd0 * pDst->m_nStride + ((xd0 >> 5) << 2);
if ((xd0 & ~31) == ((xd1 - 1) & ~31)) {
if ((xs0 & ~31) == ((xs1 - 1) & ~31)) {
if (s1 > d1) {
@@ -383,6 +381,9 @@ FX_BOOL CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
}
}
} else {
+ uint8_t* sp = nullptr;
+ uint8_t* dp = nullptr;
+
if (s1 > d1) {
shift1 = s1 - d1;
shift2 = 32 - shift1;
diff --git a/core/fxcodec/jbig2/JBig2_PatternDict.cpp b/core/fxcodec/jbig2/JBig2_PatternDict.cpp
index e74d83647c..9598dc4bae 100644
--- a/core/fxcodec/jbig2/JBig2_PatternDict.cpp
+++ b/core/fxcodec/jbig2/JBig2_PatternDict.cpp
@@ -10,7 +10,7 @@
CJBig2_PatternDict::CJBig2_PatternDict() {
NUMPATS = 0;
- HDPATS = NULL;
+ HDPATS = nullptr;
}
CJBig2_PatternDict::~CJBig2_PatternDict() {
diff --git a/core/fxcodec/jbig2/JBig2_Segment.cpp b/core/fxcodec/jbig2/JBig2_Segment.cpp
index 64df0db5f7..0f53abcee3 100644
--- a/core/fxcodec/jbig2/JBig2_Segment.cpp
+++ b/core/fxcodec/jbig2/JBig2_Segment.cpp
@@ -12,7 +12,7 @@ CJBig2_Segment::CJBig2_Segment() {
m_dwNumber = 0;
m_cFlags.c = 0;
m_nReferred_to_segment_count = 0;
- m_pReferred_to_segment_numbers = NULL;
+ m_pReferred_to_segment_numbers = nullptr;
m_dwPage_association = 0;
m_dwData_length = 0;
m_dwHeader_Length = 0;
@@ -20,7 +20,7 @@ CJBig2_Segment::CJBig2_Segment() {
m_dwDataOffset = 0;
m_State = JBIG2_SEGMENT_HEADER_UNPARSED;
m_nResultType = JBIG2_VOID_POINTER;
- m_Result.vd = NULL;
+ m_Result.vd = nullptr;
}
CJBig2_Segment::~CJBig2_Segment() {
FX_Free(m_pReferred_to_segment_numbers);
diff --git a/core/fxcodec/lbmp/fx_bmp.cpp b/core/fxcodec/lbmp/fx_bmp.cpp
index be5d93e1b8..dcf1ee11f9 100644
--- a/core/fxcodec/lbmp/fx_bmp.cpp
+++ b/core/fxcodec/lbmp/fx_bmp.cpp
@@ -40,20 +40,17 @@ void bmp_error(bmp_decompress_struct_p bmp_ptr, const FX_CHAR* err_msg) {
}
bmp_decompress_struct_p bmp_create_decompress() {
bmp_decompress_struct_p bmp_ptr = FX_Alloc(bmp_decompress_struct, 1);
- if (bmp_ptr == NULL) {
- return NULL;
- }
FXSYS_memset(bmp_ptr, 0, sizeof(bmp_decompress_struct));
bmp_ptr->decode_status = BMP_D_STATUS_HEADER;
bmp_ptr->bmp_header_ptr = FX_Alloc(BmpFileHeader, 1);
return bmp_ptr;
}
void bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) {
- if (bmp_ptr_ptr == NULL || *bmp_ptr_ptr == NULL) {
+ if (!bmp_ptr_ptr || !*bmp_ptr_ptr)
return;
- }
+
bmp_decompress_struct_p bmp_ptr = *bmp_ptr_ptr;
- *bmp_ptr_ptr = NULL;
+ *bmp_ptr_ptr = nullptr;
if (bmp_ptr->out_row_buffer) {
FX_Free(bmp_ptr->out_row_buffer);
}
@@ -62,16 +59,16 @@ void bmp_destroy_decompress(bmp_decompress_struct_pp bmp_ptr_ptr) {
FX_Free(bmp_ptr);
}
int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
- if (bmp_ptr == NULL) {
+ if (!bmp_ptr)
return 0;
- }
+
uint32_t skip_size_org = bmp_ptr->skip_size;
if (bmp_ptr->decode_status == BMP_D_STATUS_HEADER) {
ASSERT(sizeof(BmpFileHeader) == 14);
- BmpFileHeader* bmp_header_ptr = NULL;
- if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_header_ptr, 14) == NULL) {
+ BmpFileHeader* bmp_header_ptr = nullptr;
+ if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_header_ptr, 14))
return 2;
- }
+
bmp_ptr->bmp_header_ptr->bfType =
GetWord_LSBFirst((uint8_t*)&bmp_header_ptr->bfType);
bmp_ptr->bmp_header_ptr->bfOffBits =
@@ -95,9 +92,9 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
switch (bmp_ptr->img_ifh_size) {
case kBmpCoreHeaderSize: {
bmp_ptr->pal_type = 1;
- BmpCoreHeaderPtr bmp_core_header_ptr = NULL;
- if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr,
- bmp_ptr->img_ifh_size) == NULL) {
+ BmpCoreHeaderPtr bmp_core_header_ptr = nullptr;
+ if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr,
+ bmp_ptr->img_ifh_size)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -111,9 +108,9 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
bmp_ptr->imgTB_flag = FALSE;
} break;
case kBmpInfoHeaderSize: {
- BmpInfoHeaderPtr bmp_info_header_ptr = NULL;
- if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
- bmp_ptr->img_ifh_size) == NULL) {
+ BmpInfoHeaderPtr bmp_info_header_ptr = nullptr;
+ if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
+ bmp_ptr->img_ifh_size)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -139,9 +136,9 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
default: {
if (bmp_ptr->img_ifh_size >
std::min(kBmpInfoHeaderSize, sizeof(BmpInfoHeader))) {
- BmpInfoHeaderPtr bmp_info_header_ptr = NULL;
- if (bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
- bmp_ptr->img_ifh_size) == NULL) {
+ BmpInfoHeaderPtr bmp_info_header_ptr = nullptr;
+ if (!bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
+ bmp_ptr->img_ifh_size)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -229,7 +226,7 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
}
uint32_t* mask;
if (bmp_read_data(bmp_ptr, (uint8_t**)&mask, 3 * sizeof(uint32_t)) ==
- NULL) {
+ nullptr) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -258,10 +255,10 @@ int32_t bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
if (bmp_ptr->color_used != 0) {
bmp_ptr->pal_num = bmp_ptr->color_used;
}
- uint8_t* src_pal_ptr = NULL;
+ uint8_t* src_pal_ptr = nullptr;
uint32_t src_pal_size = bmp_ptr->pal_num * (bmp_ptr->pal_type ? 3 : 4);
if (bmp_read_data(bmp_ptr, (uint8_t**)&src_pal_ptr, src_pal_size) ==
- NULL) {
+ nullptr) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -321,11 +318,11 @@ int32_t bmp_decode_image(bmp_decompress_struct_p bmp_ptr) {
}
int32_t bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) {
uint8_t* row_buf = bmp_ptr->out_row_buffer;
- uint8_t* des_buf = NULL;
+ uint8_t* des_buf = nullptr;
while (bmp_ptr->row_num < bmp_ptr->height) {
- if (bmp_read_data(bmp_ptr, &des_buf, bmp_ptr->src_row_bytes) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &des_buf, bmp_ptr->src_row_bytes))
return 2;
- }
+
bmp_save_decoding_status(bmp_ptr, BMP_D_STATUS_DATA);
switch (bmp_ptr->bitCounts) {
case 1: {
@@ -384,17 +381,17 @@ int32_t bmp_decode_rgb(bmp_decompress_struct_p bmp_ptr) {
return 1;
}
int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
- uint8_t* first_byte_ptr = NULL;
- uint8_t* second_byte_ptr = NULL;
+ uint8_t* first_byte_ptr = nullptr;
+ uint8_t* second_byte_ptr = nullptr;
bmp_ptr->col_num = 0;
while (TRUE) {
uint32_t skip_size_org = bmp_ptr->skip_size;
- if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1))
return 2;
- }
+
switch (*first_byte_ptr) {
case RLE_MARKER: {
- if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -428,7 +425,7 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
}
case RLE_DELTA: {
uint8_t* delta_ptr;
- if (bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &delta_ptr, 2)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -454,9 +451,9 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
bmp_error(bmp_ptr, "The Bmp File Is Corrupt");
return 0;
}
- if (bmp_read_data(bmp_ptr, &second_byte_ptr,
- *first_byte_ptr & 1 ? *first_byte_ptr + 1
- : *first_byte_ptr) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &second_byte_ptr,
+ *first_byte_ptr & 1 ? *first_byte_ptr + 1
+ : *first_byte_ptr)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -467,7 +464,7 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
}
} break;
default: {
- if (bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &second_byte_ptr, 1)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -486,17 +483,17 @@ int32_t bmp_decode_rle8(bmp_decompress_struct_p bmp_ptr) {
return 0;
}
int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
- uint8_t* first_byte_ptr = NULL;
- uint8_t* second_byte_ptr = NULL;
+ uint8_t* first_byte_ptr = nullptr;
+ uint8_t* second_byte_ptr = nullptr;
bmp_ptr->col_num = 0;
while (TRUE) {
uint32_t skip_size_org = bmp_ptr->skip_size;
- if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1))
return 2;
- }
+
switch (*first_byte_ptr) {
case RLE_MARKER: {
- if (bmp_read_data(bmp_ptr, &first_byte_ptr, 1) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &first_byte_ptr, 1)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -530,7 +527,7 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
}
case RLE_DELTA: {
uint8_t* delta_ptr;
- if (bmp_read_data(bmp_ptr, &delta_ptr, 2) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &delta_ptr, 2)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -560,8 +557,8 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
}
*first_byte_ptr = bmp_ptr->out_row_bytes - bmp_ptr->col_num - 1;
}
- if (bmp_read_data(bmp_ptr, &second_byte_ptr,
- size & 1 ? size + 1 : size) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &second_byte_ptr,
+ size & 1 ? size + 1 : size)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -578,7 +575,7 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
}
} break;
default: {
- if (bmp_read_data(bmp_ptr, &second_byte_ptr, 1) == NULL) {
+ if (!bmp_read_data(bmp_ptr, &second_byte_ptr, 1)) {
bmp_ptr->skip_size = skip_size_org;
return 2;
}
@@ -609,9 +606,9 @@ int32_t bmp_decode_rle4(bmp_decompress_struct_p bmp_ptr) {
uint8_t* bmp_read_data(bmp_decompress_struct_p bmp_ptr,
uint8_t** des_buf_pp,
uint32_t data_size) {
- if (bmp_ptr == NULL || bmp_ptr->avail_in < bmp_ptr->skip_size + data_size) {
- return NULL;
- }
+ if (!bmp_ptr || bmp_ptr->avail_in < bmp_ptr->skip_size + data_size)
+ return nullptr;
+
*des_buf_pp = bmp_ptr->next_in + bmp_ptr->skip_size;
bmp_ptr->skip_size += data_size;
return *des_buf_pp;
@@ -630,11 +627,11 @@ void bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
bmp_ptr->skip_size = 0;
}
uint32_t bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
- uint8_t** avial_buf_ptr) {
- if (avial_buf_ptr) {
- *avial_buf_ptr = NULL;
+ uint8_t** avail_buf_ptr) {
+ if (avail_buf_ptr) {
+ *avail_buf_ptr = nullptr;
if (bmp_ptr->avail_in > 0) {
- *avial_buf_ptr = bmp_ptr->next_in;
+ *avail_buf_ptr = bmp_ptr->next_in;
}
}
return bmp_ptr->avail_in;
@@ -708,9 +705,6 @@ static void bmp_encode_bitfields(bmp_compress_struct_p bmp_ptr,
dst_pos = bmp_ptr->file_header.bfOffBits;
dst_size += size;
dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size);
- if (dst_buf == NULL) {
- return;
- }
FXSYS_memset(&dst_buf[dst_pos], 0, size);
uint32_t mask_red;
uint32_t mask_green;
@@ -795,9 +789,6 @@ static void bmp_encode_rgb(bmp_compress_struct_p bmp_ptr,
dst_pos = bmp_ptr->file_header.bfOffBits;
dst_size += size;
dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size);
- if (dst_buf == NULL) {
- return;
- }
FXSYS_memset(&dst_buf[dst_pos], 0, size);
for (int32_t row_num = bmp_ptr->src_row - 1; row_num > -1; row_num--) {
FXSYS_memcpy(&dst_buf[dst_pos],
@@ -827,9 +818,6 @@ static void bmp_encode_rle8(bmp_compress_struct_p bmp_ptr,
dst_pos = bmp_ptr->file_header.bfOffBits;
dst_size += size;
dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size);
- if (dst_buf == NULL) {
- return;
- }
FXSYS_memset(&dst_buf[dst_pos], 0, size);
for (int32_t row_num = bmp_ptr->src_row - 1, i = 0; row_num > -1;) {
index = row_num * bmp_ptr->src_pitch;
@@ -875,9 +863,6 @@ static void bmp_encode_rle4(bmp_compress_struct_p bmp_ptr,
dst_pos = bmp_ptr->file_header.bfOffBits;
dst_size += size;
dst_buf = FX_Realloc(uint8_t, dst_buf, dst_size);
- if (dst_buf == NULL) {
- return;
- }
FXSYS_memset(&dst_buf[dst_pos], 0, size);
for (int32_t row_num = bmp_ptr->src_row - 1, i = 0; row_num > -1;
rle[1] = 0) {
@@ -916,9 +901,9 @@ FX_BOOL bmp_encode_image(bmp_compress_struct_p bmp_ptr,
}
dst_size = head_size + sizeof(uint32_t) * bmp_ptr->pal_num;
dst_buf = FX_TryAlloc(uint8_t, dst_size);
- if (dst_buf == NULL) {
+ if (!dst_buf)
return FALSE;
- }
+
FXSYS_memset(dst_buf, 0, dst_size);
bmp_ptr->file_header.bfOffBits = head_size;
if (bmp_ptr->pal_ptr && pal_size) {
diff --git a/core/fxcodec/lbmp/fx_bmp.h b/core/fxcodec/lbmp/fx_bmp.h
index 870eae478c..5c4837807f 100644
--- a/core/fxcodec/lbmp/fx_bmp.h
+++ b/core/fxcodec/lbmp/fx_bmp.h
@@ -125,7 +125,7 @@ void bmp_input_buffer(bmp_decompress_struct_p bmp_ptr,
uint8_t* src_buf,
uint32_t src_size);
uint32_t bmp_get_avail_input(bmp_decompress_struct_p bmp_ptr,
- uint8_t** avial_buf_ptr);
+ uint8_t** avail_buf_ptr);
typedef struct tag_bmp_compress_struct bmp_compress_struct;
typedef bmp_compress_struct* bmp_compress_struct_p;
typedef bmp_compress_struct_p* bmp_compress_struct_pp;
diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp
index 53298c831a..e22bbc7774 100644
--- a/core/fxcodec/lgif/fx_gif.cpp
+++ b/core/fxcodec/lgif/fx_gif.cpp
@@ -21,7 +21,7 @@ void CGifLZWDecoder::InitTable(uint8_t code_len) {
code_end = code_clear + 1;
bits_left = 0;
code_store = 0;
- next_in = NULL;
+ next_in = nullptr;
avail_in = 0;
stack_size = 0;
code_first = 0;
@@ -151,17 +151,15 @@ static FX_BOOL gif_grow_buf(uint8_t*& dst_buf,
uint32_t len_org = dst_len;
while (dst_buf && dst_len < size) {
dst_len <<= 1;
+ // TODO(thestig): Probably should be a try-realloc here.
dst_buf = FX_Realloc(uint8_t, dst_buf, dst_len);
}
- if (dst_buf == NULL) {
+ if (!dst_buf) {
dst_len = size;
dst_buf = FX_Realloc(uint8_t, dst_buf, dst_len);
- if (dst_buf == NULL) {
- return FALSE;
- }
}
FXSYS_memset(dst_buf + len_org, 0, dst_len - len_org);
- return dst_buf != NULL;
+ return !!dst_buf;
}
return TRUE;
}
@@ -359,9 +357,9 @@ void CGifLZWEncoder::Finish(uint8_t*& dst_buf,
gif_decompress_struct_p gif_create_decompress() {
gif_decompress_struct_p gif_ptr =
(gif_decompress_struct*)FX_Alloc(uint8_t, sizeof(gif_decompress_struct));
- if (gif_ptr == NULL) {
- return NULL;
- }
+ if (!gif_ptr)
+ return nullptr;
+
FXSYS_memset(gif_ptr, 0, sizeof(gif_decompress_struct));
gif_ptr->decode_status = GIF_D_STATUS_SIG;
gif_ptr->img_ptr_arr_ptr = new CFX_ArrayTemplate<GifImage*>;
@@ -370,11 +368,11 @@ gif_decompress_struct_p gif_create_decompress() {
return gif_ptr;
}
void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
- if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) {
+ if (!gif_ptr_ptr || !*gif_ptr_ptr)
return;
- }
+
gif_decompress_struct_p gif_ptr = *gif_ptr_ptr;
- *gif_ptr_ptr = NULL;
+ *gif_ptr_ptr = nullptr;
FX_Free(gif_ptr->global_pal_ptr);
delete gif_ptr->img_decoder_ptr;
if (gif_ptr->img_ptr_arr_ptr) {
@@ -410,66 +408,66 @@ void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
gif_compress_struct_p gif_create_compress() {
gif_compress_struct_p gif_ptr =
(gif_compress_struct*)FX_Alloc(uint8_t, sizeof(gif_compress_struct));
- if (gif_ptr == NULL) {
- return NULL;
- }
+ if (!gif_ptr)
+ return nullptr;
+
FXSYS_memset(gif_ptr, 0, sizeof(gif_compress_struct));
gif_ptr->img_encoder_ptr = new CGifLZWEncoder;
gif_ptr->header_ptr = (GifHeader*)FX_Alloc(uint8_t, sizeof(GifHeader));
- if (gif_ptr->header_ptr == NULL) {
+ if (!gif_ptr->header_ptr) {
delete (gif_ptr->img_encoder_ptr);
FX_Free(gif_ptr);
- return NULL;
+ return nullptr;
}
FXSYS_memcpy(gif_ptr->header_ptr->signature, GIF_SIGNATURE, 3);
FXSYS_memcpy(gif_ptr->header_ptr->version, "89a", 3);
gif_ptr->lsd_ptr = (GifLSD*)FX_Alloc(uint8_t, sizeof(GifLSD));
- if (gif_ptr->lsd_ptr == NULL) {
+ if (!gif_ptr->lsd_ptr) {
FX_Free(gif_ptr->header_ptr);
delete (gif_ptr->img_encoder_ptr);
FX_Free(gif_ptr);
- return NULL;
+ return nullptr;
}
FXSYS_memset(gif_ptr->lsd_ptr, 0, sizeof(GifLSD));
gif_ptr->image_info_ptr =
(GifImageInfo*)FX_Alloc(uint8_t, sizeof(GifImageInfo));
- if (gif_ptr->image_info_ptr == NULL) {
+ if (!gif_ptr->image_info_ptr) {
FX_Free(gif_ptr->lsd_ptr);
FX_Free(gif_ptr->header_ptr);
delete (gif_ptr->img_encoder_ptr);
FX_Free(gif_ptr);
- return NULL;
+ return nullptr;
}
FXSYS_memset(gif_ptr->image_info_ptr, 0, sizeof(GifImageInfo));
gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE));
- if (gif_ptr->gce_ptr == NULL) {
+ if (!gif_ptr->gce_ptr) {
FX_Free(gif_ptr->image_info_ptr);
FX_Free(gif_ptr->lsd_ptr);
FX_Free(gif_ptr->header_ptr);
delete (gif_ptr->img_encoder_ptr);
FX_Free(gif_ptr);
- return NULL;
+ return nullptr;
}
gif_ptr->pte_ptr = (GifPTE*)FX_Alloc(uint8_t, sizeof(GifPTE));
- if (gif_ptr->pte_ptr == NULL) {
+ if (!gif_ptr->pte_ptr) {
FX_Free(gif_ptr->gce_ptr);
FX_Free(gif_ptr->image_info_ptr);
FX_Free(gif_ptr->lsd_ptr);
FX_Free(gif_ptr->header_ptr);
delete (gif_ptr->img_encoder_ptr);
FX_Free(gif_ptr);
- return NULL;
+ return nullptr;
}
FXSYS_memset(gif_ptr->pte_ptr, 0, sizeof(GifPTE));
gif_ptr->pte_ptr->block_size = 12;
return gif_ptr;
}
void gif_destroy_compress(gif_compress_struct_pp gif_ptr_ptr) {
- if (gif_ptr_ptr == NULL || *gif_ptr_ptr == NULL) {
+ if (!gif_ptr_ptr || !*gif_ptr_ptr)
return;
- }
+
gif_compress_struct_p gif_ptr = *gif_ptr_ptr;
- *gif_ptr_ptr = NULL;
+ *gif_ptr_ptr = nullptr;
FX_Free(gif_ptr->header_ptr);
FX_Free(gif_ptr->lsd_ptr);
FX_Free(gif_ptr->global_pal);
@@ -488,23 +486,23 @@ void gif_error(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {
}
void gif_warn(gif_decompress_struct_p gif_ptr, const FX_CHAR* err_msg) {}
int32_t gif_read_header(gif_decompress_struct_p gif_ptr) {
- if (gif_ptr == NULL) {
+ if (!gif_ptr)
return 0;
- }
+
uint32_t skip_size_org = gif_ptr->skip_size;
ASSERT(sizeof(GifHeader) == 6);
- GifHeader* gif_header_ptr = NULL;
- if (gif_read_data(gif_ptr, (uint8_t**)&gif_header_ptr, 6) == NULL) {
+ GifHeader* gif_header_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, (uint8_t**)&gif_header_ptr, 6))
return 2;
- }
+
if (FXSYS_strncmp(gif_header_ptr->signature, GIF_SIGNATURE, 3) != 0 ||
gif_header_ptr->version[0] != '8' || gif_header_ptr->version[2] != 'a') {
gif_error(gif_ptr, "Not A Gif Image");
return 0;
}
ASSERT(sizeof(GifLSD) == 7);
- GifLSD* gif_lsd_ptr = NULL;
- if (gif_read_data(gif_ptr, (uint8_t**)&gif_lsd_ptr, 7) == NULL) {
+ GifLSD* gif_lsd_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, (uint8_t**)&gif_lsd_ptr, 7)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -513,8 +511,8 @@ int32_t gif_read_header(gif_decompress_struct_p gif_ptr) {
<< ((GifGF*)&gif_lsd_ptr->global_flag)->pal_bits;
ASSERT(sizeof(GifPalette) == 3);
int32_t global_pal_size = gif_ptr->global_pal_num * 3;
- uint8_t* global_pal_ptr = NULL;
- if (gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size) == NULL) {
+ uint8_t* global_pal_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, &global_pal_ptr, global_pal_size)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -532,19 +530,19 @@ int32_t gif_read_header(gif_decompress_struct_p gif_ptr) {
return 1;
}
int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) {
- if (gif_ptr == NULL) {
+ if (!gif_ptr)
return 0;
- }
+
int32_t ret = 1;
while (TRUE) {
switch (gif_ptr->decode_status) {
case GIF_D_STATUS_TAIL:
return 1;
case GIF_D_STATUS_SIG: {
- uint8_t* sig_ptr = NULL;
- if (gif_read_data(gif_ptr, &sig_ptr, 1) == NULL) {
+ uint8_t* sig_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, &sig_ptr, 1))
return 2;
- }
+
switch (*sig_ptr) {
case GIF_SIG_EXTENSION:
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT);
@@ -566,10 +564,10 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) {
}
}
case GIF_D_STATUS_EXT: {
- uint8_t* ext_ptr = NULL;
- if (gif_read_data(gif_ptr, &ext_ptr, 1) == NULL) {
+ uint8_t* ext_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, &ext_ptr, 1))
return 2;
- }
+
switch (*ext_ptr) {
case GIF_BLOCK_CE:
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_EXT_CE);
@@ -598,22 +596,21 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) {
continue;
}
case GIF_D_STATUS_IMG_DATA: {
- uint8_t* data_size_ptr = NULL;
- uint8_t* data_ptr = NULL;
+ uint8_t* data_size_ptr = nullptr;
+ uint8_t* data_ptr = nullptr;
uint32_t skip_size_org = gif_ptr->skip_size;
- if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_size_ptr, 1))
return 2;
- }
+
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
skip_size_org = gif_ptr->skip_size;
- if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_size_ptr, 1))
return 2;
- }
}
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_SIG);
continue;
@@ -631,27 +628,27 @@ int32_t gif_get_frame(gif_decompress_struct_p gif_ptr) {
}
void gif_takeover_gce_ptr(gif_decompress_struct_p gif_ptr,
GifGCE** gce_ptr_ptr) {
- *gce_ptr_ptr = NULL;
+ *gce_ptr_ptr = nullptr;
if (gif_ptr->gce_ptr && gce_ptr_ptr) {
*gce_ptr_ptr = gif_ptr->gce_ptr;
- gif_ptr->gce_ptr = NULL;
+ gif_ptr->gce_ptr = nullptr;
}
}
int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
- uint8_t* data_size_ptr = NULL;
- uint8_t* data_ptr = NULL;
+ uint8_t* data_size_ptr = nullptr;
+ uint8_t* data_ptr = nullptr;
uint32_t skip_size_org = gif_ptr->skip_size;
switch (gif_ptr->decode_status) {
case GIF_D_STATUS_EXT_CE: {
- if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
gif_ptr->cmt_data_ptr->clear();
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
uint8_t data_size = *data_size_ptr;
- if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
- gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) ||
+ !gif_read_data(gif_ptr, &data_size_ptr, 1)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -661,8 +658,8 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
} break;
case GIF_D_STATUS_EXT_PTE: {
ASSERT(sizeof(GifPTE) == 13);
- GifPTE* gif_pte_ptr = NULL;
- if (gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13) == NULL) {
+ GifPTE* gif_pte_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, (uint8_t**)&gif_pte_ptr, 13)) {
return 2;
}
GifPlainText* gif_pt_ptr = FX_Alloc(GifPlainText, 1);
@@ -683,7 +680,7 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
gif_pt_ptr->pte_ptr->char_height = gif_pte_ptr->char_height;
gif_pt_ptr->pte_ptr->fc_index = gif_pte_ptr->fc_index;
gif_pt_ptr->pte_ptr->bc_index = gif_pte_ptr->bc_index;
- if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_size_ptr, 1)) {
gif_ptr->skip_size = skip_size_org;
if (gif_pt_ptr) {
FX_Free(gif_pt_ptr->gce_ptr);
@@ -695,8 +692,8 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
}
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
uint8_t data_size = *data_size_ptr;
- if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
- gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) ||
+ !gif_read_data(gif_ptr, &data_size_ptr, 1)) {
gif_ptr->skip_size = skip_size_org;
if (gif_pt_ptr) {
FX_Free(gif_pt_ptr->gce_ptr);
@@ -713,13 +710,12 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
} break;
case GIF_D_STATUS_EXT_GCE: {
ASSERT(sizeof(GifGCE) == 5);
- GifGCE* gif_gce_ptr = NULL;
- if (gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6) == NULL) {
+ GifGCE* gif_gce_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, (uint8_t**)&gif_gce_ptr, 6))
return 2;
- }
- if (gif_ptr->gce_ptr == NULL) {
+
+ if (!gif_ptr->gce_ptr)
gif_ptr->gce_ptr = (GifGCE*)FX_Alloc(uint8_t, sizeof(GifGCE));
- }
gif_ptr->gce_ptr->block_size = gif_gce_ptr->block_size;
gif_ptr->gce_ptr->gce_flag = gif_gce_ptr->gce_flag;
gif_ptr->gce_ptr->delay_time =
@@ -729,14 +725,14 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
default: {
if (gif_ptr->decode_status == GIF_D_STATUS_EXT_PTE) {
FX_Free(gif_ptr->gce_ptr);
- gif_ptr->gce_ptr = NULL;
+ gif_ptr->gce_ptr = nullptr;
}
- if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_size_ptr, 1))
return 2;
- }
+
while (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL ||
- gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) ||
+ !gif_read_data(gif_ptr, &data_size_ptr, 1)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -753,10 +749,10 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
}
uint32_t skip_size_org = gif_ptr->skip_size;
ASSERT(sizeof(GifImageInfo) == 9);
- GifImageInfo* gif_img_info_ptr = NULL;
- if (gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9) == NULL) {
+ GifImageInfo* gif_img_info_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, (uint8_t**)&gif_img_info_ptr, 9))
return 2;
- }
+
GifImage* gif_image_ptr = (GifImage*)FX_Alloc(uint8_t, sizeof(GifImage));
FXSYS_memset(gif_image_ptr, 0, sizeof(GifImage));
gif_image_ptr->image_info_ptr =
@@ -786,8 +782,8 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
if (gif_img_info_lf_ptr->local_pal) {
ASSERT(sizeof(GifPalette) == 3);
int32_t loc_pal_size = (2 << gif_img_info_lf_ptr->pal_bits) * 3;
- uint8_t* loc_pal_ptr = NULL;
- if (gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size) == NULL) {
+ uint8_t* loc_pal_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, &loc_pal_ptr, loc_pal_size)) {
gif_ptr->skip_size = skip_size_org;
FX_Free(gif_image_ptr->image_info_ptr);
FX_Free(gif_image_ptr->image_row_buf);
@@ -801,8 +797,8 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
loc_pal_size);
}
}
- uint8_t* code_size_ptr = NULL;
- if (gif_read_data(gif_ptr, &code_size_ptr, 1) == NULL) {
+ uint8_t* code_size_ptr = nullptr;
+ if (!gif_read_data(gif_ptr, &code_size_ptr, 1)) {
gif_ptr->skip_size = skip_size_org;
FX_Free(gif_image_ptr->image_info_ptr);
FX_Free(gif_image_ptr->local_pal_ptr);
@@ -820,19 +816,19 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
return 1;
}
int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
- if (gif_ptr == NULL || frame_num < 0 ||
+ if (!gif_ptr || frame_num < 0 ||
frame_num >= gif_ptr->img_ptr_arr_ptr->GetSize()) {
return 0;
}
- uint8_t* data_size_ptr = NULL;
- uint8_t* data_ptr = NULL;
+ uint8_t* data_size_ptr = nullptr;
+ uint8_t* data_ptr = nullptr;
uint32_t skip_size_org = gif_ptr->skip_size;
GifImage* gif_image_ptr = gif_ptr->img_ptr_arr_ptr->GetAt(frame_num);
uint32_t gif_img_row_bytes = gif_image_ptr->image_info_ptr->width;
if (gif_ptr->decode_status == GIF_D_STATUS_TAIL) {
if (gif_image_ptr->image_row_buf) {
FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = NULL;
+ gif_image_ptr->image_row_buf = nullptr;
}
gif_image_ptr->image_row_buf = FX_Alloc(uint8_t, gif_img_row_bytes);
GifGCE* gif_img_gce_ptr = gif_image_ptr->image_gce_ptr;
@@ -842,7 +838,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
->pal_bits)
: 0;
gif_ptr->avail_in = 0;
- if (gif_img_gce_ptr == NULL) {
+ if (!gif_img_gce_ptr) {
FX_BOOL bRes = gif_ptr->gif_get_record_position_fn(
gif_ptr, gif_image_ptr->image_data_pos,
gif_image_ptr->image_info_ptr->left,
@@ -854,7 +850,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
->interlace);
if (!bRes) {
FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = NULL;
+ gif_image_ptr->image_row_buf = nullptr;
gif_error(gif_ptr, "Error Read Record Position Data");
return 0;
}
@@ -878,14 +874,13 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
->interlace);
if (!bRes) {
FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = NULL;
+ gif_image_ptr->image_row_buf = nullptr;
gif_error(gif_ptr, "Error Read Record Position Data");
return 0;
}
}
- if (gif_ptr->img_decoder_ptr == NULL) {
+ if (!gif_ptr->img_decoder_ptr)
gif_ptr->img_decoder_ptr = new CGifLZWDecoder(gif_ptr->err_ptr);
- }
gif_ptr->img_decoder_ptr->InitTable(gif_image_ptr->image_code_size);
gif_ptr->img_row_offset = 0;
gif_ptr->img_row_avail_size = 0;
@@ -895,11 +890,11 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
}
CGifLZWDecoder* img_decoder_ptr = gif_ptr->img_decoder_ptr;
if (gif_ptr->decode_status == GIF_D_STATUS_IMG_DATA) {
- if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_size_ptr, 1))
return 2;
- }
+
if (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -912,7 +907,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
gif_ptr->img_row_avail_size);
if (ret == 0) {
FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = NULL;
+ gif_image_ptr->image_row_buf = nullptr;
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
gif_error(gif_ptr, "Decode Image Data Error");
return 0;
@@ -922,18 +917,18 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
gif_ptr->gif_get_row_fn(gif_ptr, gif_image_ptr->image_row_num,
gif_image_ptr->image_row_buf);
FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = NULL;
+ gif_image_ptr->image_row_buf = nullptr;
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
return 1;
}
if (ret == 2) {
ASSERT(img_decoder_ptr->GetAvailInput() == 0);
skip_size_org = gif_ptr->skip_size;
- if (gif_read_data(gif_ptr, &data_size_ptr, 1) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_size_ptr, 1))
return 2;
- }
+
if (*data_size_ptr != GIF_BLOCK_TERMINAL) {
- if (gif_read_data(gif_ptr, &data_ptr, *data_size_ptr) == NULL) {
+ if (!gif_read_data(gif_ptr, &data_ptr, *data_size_ptr)) {
gif_ptr->skip_size = skip_size_org;
return 2;
}
@@ -971,7 +966,7 @@ int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
}
if (ret == 0) {
FX_Free(gif_image_ptr->image_row_buf);
- gif_image_ptr->image_row_buf = NULL;
+ gif_image_ptr->image_row_buf = nullptr;
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_TAIL);
gif_error(gif_ptr, "Decode Image Data Error");
return 0;
@@ -992,9 +987,9 @@ void gif_save_decoding_status(gif_decompress_struct_p gif_ptr, int32_t status) {
uint8_t* gif_read_data(gif_decompress_struct_p gif_ptr,
uint8_t** des_buf_pp,
uint32_t data_size) {
- if (gif_ptr == NULL || gif_ptr->avail_in < gif_ptr->skip_size + data_size) {
- return NULL;
- }
+ if (!gif_ptr || gif_ptr->avail_in < gif_ptr->skip_size + data_size)
+ return nullptr;
+
*des_buf_pp = gif_ptr->next_in + gif_ptr->skip_size;
gif_ptr->skip_size += data_size;
return *des_buf_pp;
@@ -1007,11 +1002,11 @@ void gif_input_buffer(gif_decompress_struct_p gif_ptr,
gif_ptr->skip_size = 0;
}
uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr,
- uint8_t** avial_buf_ptr) {
- if (avial_buf_ptr) {
- *avial_buf_ptr = NULL;
+ uint8_t** avail_buf_ptr) {
+ if (avail_buf_ptr) {
+ *avail_buf_ptr = nullptr;
if (gif_ptr->avail_in > 0) {
- *avial_buf_ptr = gif_ptr->next_in;
+ *avail_buf_ptr = gif_ptr->next_in;
}
}
return gif_ptr->avail_in;
@@ -1027,9 +1022,9 @@ static FX_BOOL gif_write_header(gif_compress_struct_p gif_ptr,
}
dst_len = sizeof(GifHeader) + sizeof(GifLSD) + sizeof(GifGF);
dst_buf = FX_TryAlloc(uint8_t, dst_len);
- if (dst_buf == NULL) {
+ if (!dst_buf)
return FALSE;
- }
+
FXSYS_memset(dst_buf, 0, dst_len);
FXSYS_memcpy(dst_buf, gif_ptr->header_ptr, sizeof(GifHeader));
gif_ptr->cur_offset += sizeof(GifHeader);
@@ -1067,9 +1062,6 @@ void interlace_buf(const uint8_t* buf, uint32_t pitch, uint32_t height) {
j = 3;
}
temp = FX_Alloc(uint8_t, pitch);
- if (temp == NULL) {
- return;
- }
FXSYS_memcpy(temp, &buf[pitch * row], pitch);
pass[j].Add(temp);
row++;
diff --git a/core/fxcodec/lgif/fx_gif.h b/core/fxcodec/lgif/fx_gif.h
index 47e5eebab7..7d325fb3fe 100644
--- a/core/fxcodec/lgif/fx_gif.h
+++ b/core/fxcodec/lgif/fx_gif.h
@@ -118,7 +118,7 @@ class CGifLZWDecoder {
uint16_t prefix;
uint8_t suffix;
};
- CGifLZWDecoder(FX_CHAR* error_ptr = NULL) { err_msg_ptr = error_ptr; }
+ CGifLZWDecoder(FX_CHAR* error_ptr = nullptr) { err_msg_ptr = error_ptr; }
void InitTable(uint8_t code_len);
int32_t Decode(uint8_t* des_buf, uint32_t& des_size);
@@ -287,7 +287,7 @@ void gif_input_buffer(gif_decompress_struct_p gif_ptr,
uint8_t* src_buf,
uint32_t src_size);
uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr,
- uint8_t** avial_buf_ptr);
+ uint8_t** avail_buf_ptr);
void interlace_buf(const uint8_t* buf, uint32_t width, uint32_t height);
FX_BOOL gif_encode(gif_compress_struct_p gif_ptr,
uint8_t*& dst_buf,